Using sklearn knn imputation on a large dataset
You could use a memmap
import numpy as np
from tempfile import mkdtemp
import os.path as path
filename = path.join(mkdtemp(), 'newfile.dat') # or you could use another dat file that already constains your dataset

# supposing your data is loaded in a variable named &quot;data&quot;

fp = np.memmap(filename, dtype='float32', mode='w+', shape=data.shape)
fp[:] = data[:]

You can check full documentation on this page, the code above is based on the documentation.
This way you:

only change the declaration of your data matrices, keeping you code as clean as possible
uses numpy built-in ndarray subclass without having to explicitly manage data retrieval from the disk