我对单个变量进行了修改并将其返回到同一个变量
X = pd.DataFrame(df, columns=['a'])
imp = Imputer(missing_values='NaN', strategy='median', axis=0)
X = imp.fit_transform(X)
df['a'] = X
但是我有很多变量&想像这样使用循环
f = df[[a, b, c, d, e]]
for k in f:
X = pd.DataFrame(df, columns=k)
imp = Imputer(missing_values='NaN', strategy='median', axis=0)
X = imp.fit_transform(X)
df.k = X
但:
TypeError: Index(...) must be called with a collection of some kind, 'a' was passed
如何在数据框中使用循环进行插补和返回变量?