我的代码是很简单,但它总是弹出这样的警告:折旧警告当我使用sklearn imputer
DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will
raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if
your data has a single feature or X.reshape(1, -1) if it contains a single sample.
(DeprecationWarning)
我不知道为什么它,即使我在添加s.reshape(-1,1)
不起作用圆括号fit_transforms
。
的代码如下:
import pandas as pd
s = pd.Series([1,2,3,np.nan,5,np.nan,7,8])
imp = Imputer(missing_values='NAN', strategy='mean', axis=0)
x = pd.Series(imp.fit_transform(s).tolist()[0])
x
请尝试导入您正在使用的所有库。例如,presumba'pd'是熊猫,但不确定每个人都会猜到。 –
那么你是否会收到警告或错误?如果出现警告,代码仍然应该执行,所以如果没有,您可能会遇到其他问题 – UnholySheep