28x28 mnist image unrolling to concatenate using numpy.vstack. Why is numpy.vstack so slow?
You can reshape a numpy array simply by:
newxdata =  xdata.reshape((60000,28*28))

for example. Or simply:
newxdata =  xdata.reshape((len(xdata),-1))

Note that reshape is a numpy function which can used also as:
import numpy as np
newxdata =  np.reshape(xdata, (60000,-1))

To speed up your loop you could alternatively use libraries like multiprocessing.Pool or CuPy or Numba.