How to replace NaN values for image data?
Given you have images stretched out as columns in a table with ~48,500 rows, I am assuming you have the raw images that are 220x220 in dimension. 

You can use a function available via OpenCV called inpaint, which will restore missing pixel values (for example black pixels of degraded photos).

Here is an image example. Top-left shows the image with missing values (in black). Top-right shows just the missing values (the mask). Bottom-left and bottom-right are the final output, comparing two different algorithms for filling the images.



I would suggest trying both methods on your images to see what looks best.

Have a look at the Documentation for more details on the algorithms themselves. Here is the documentation of the actual function.

As for code, it will look something like this:

import opencv as cv    # you will need to install OpenCV

dst = cv.inpaint(img, mask, 3, cv.INPAINT_TELEA)



the first argument is your image with missing values
the second is the mask, with locations of where missing pixels are, i.e. which pixels should be filled/interpolated.
third is the radius around missing pixels to fill
fourth is the flag for the algorithm to use (see link above for two alternatives)


For each image, you can generate the mask with something like this:

mask = image[image == np.nan]