KeyError:(nan,“出现在索引95”)

我正在处理数据集,但它缺少一些值。我正在努力填补这些价值观。 这是我的代码的片段。

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']]

df['LoanAmount'].fillna(df[df['LoanAmount'].isnull()].apply(fage, axis=1), inplace=True)

这显示了以下错误。

KeyError: (nan, 'occurred at index 95') 

here is a snap of dataset.dataset snap

I don't know why this error has occured, although there is nan

at index 95 of column LoanAmount

评论