目前,我正在就有关问题进行讨论。我不确定为什么会中断以及需要进行哪些修改。
代码:
File "<ipython-input-15-dadf94659135>", line 1, in <module>
df['LoanAmount'].fillna(df[df['LoanAmount'].isnull()].apply(fage,axis=1),inplace =True)
File "/home/aryabhatta/anaconda3/lib/python3.6/site-packages/pandas/core/series.py", line 3422, in fillna
**kwargs)
File "/home/aryabhatta/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py", line 5400, in fillna
'"{0}"'.format(type(value).__name__))
TypeError: "value" parameter must be a scalar, dict or Series, but you passed a "DataFrame"
输出:
[15]:df ['LoanAmount']。fillna(df [df ['LoanAmount']。isnull()]。apply(fage,axis = 1),inplace = True)
回溯(最近通话最近一次):
@Override
protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
答案 0 :(得分:0)
嗨,请确保
我希望您在填写LoanAmount的缺失值之前不要执行此行
df['LoanAmount'].fillna(df['LoanAmount'].mean(), inplace=True)
错误是LoanAmount已被其他值填充,并且其中没有缺失值,因此引发错误。
替换缺少的值:
df['LoanAmount'].fillna(df[df['LoanAmount'].isnull()].apply(fage,axis=1),inplace =True
在执行上述代码之前,请确保LoanAmount
缺少值,请在命令下方执行检查。
df.apply(lambda x: sum(x.isnull()),axis=0)
以上命令将显示LoanAmount
的丢失计数。如果缺少值,则只能用Fage或Mean代替。