0
imp = SimpleImputer(missing_values=np.nan, strategy='most_frequent')
weather_test = imp.fit_transform(weather_test)

The above code is throwing error in google colab when weather_test is a pandas dataframe. But when I change weather_test to numpy array, it works.

imp = SimpleImputer(missing_values=np.nan, strategy='most_frequent', verbose=0)
weather_test = imp.fit_transform(np.array(weather_test))
jakevdp
  • 77,104
  • 11
  • 125
  • 160

1 Answers1

0

Scikit-learn's API methods generally assume the input will be a numpy array rather than a pandas dataframe. For an example of how to use this functionality with a dataframe, see How to use sklearn fit_transform with pandas and return dataframe instead of numpy array?

jakevdp
  • 77,104
  • 11
  • 125
  • 160