How to fix TypeError in spyder?
You might try it without the double quotes around the np.NaN and do not forget to import numpy (import numpy as np)

As a sidenote, you should use SimpleImputer instead of Imputer:

Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.