目前我正在讨论主题问题。我不知道它为什么会破裂,需要做哪些修改。在
代码:
table = df.pivot_table(values='LoanAmount', index='Self_Employed' ,columns='Education', aggfunc=np.median)
def fage(x):
return table.loc[x['Self_Employed'],x['Education']]
#Replacing missing values
df['LoanAmount'].fillna(df[df['LoanAmount'].isnull()].apply(fage,axis=1),inplace =True)
输出:
[15]:df['LoanAmount'].fillna(df['LoanAmount'].isnull()].apply(fage,axis=1),inplace=True)
回溯(最近一次呼叫):
^{pr2}$
嗨,请确保
我希望您之前没有执行这行来填充LoanAmount的缺失值
错误是LoanAmount已经用其他值填充,并且中没有缺少值所以呢它抛出错误。在
替换缺少的值:
^{pr2}$在执行上述代码之前,请确保
LoanAmount
中缺少值execute below命令以进行检查。在上面的命令将显示
LoanAmount
的缺失计数。如果缺少值,则只能用fage或mean替换。在相关问题 更多 >
编程相关推荐