I have a 2d numpy array that was created with:
array = dataset.to_numpy()
X = array[:, 1:]
I want to use OrdinalEncoder, but there are some Nans in X that I want to impute. I can't run OrdinalEncoder because it doesn't like the Nans and I can't run the KNNImputer until I encode.
I know I can replace the Nan with something like '?', etc and then OrdinalEncoder() will work, but then I have to go through and replace the numbers that the '?' turned into back to Nan. That means looping through the OrdinalEncoder internals to figure out what the '?' was mapped to in each column and then doing a replace on that column.
Isn't there a better way to do this? I was trying to get masking to work, but couldn't figure it out. I need to operate on X and not the dataset.