В настоящее время я ломаюсь по предмету.Я не уверен, почему он ломается и какие изменения требуются.
Код:
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 [df ['LoanAmount']. isnull ()]. apply (fage, axis = 1), inplace = True)
Отслеживание (последний последний вызов):
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"