菜鸟问题求助:缺失值如何用中位数或平均值填充?
测试数据如下:import numpy as np
import pandas as pd
from numpy import nan as NA
x=pd.DataFrame(np.arange(15).reshape(5,3), index=list('defgh'), columns=list('abc'))
x.loc['e']=None
x.loc['f','b']=None
结果如下:
Out[59]:
a b c
d 0.0 1.0 2.0
e NaN NaN NaN
f 6.0 NaN 8.0
g 9.0 10.0 11.0
h 12.0 13.0 14.0
菜鸟问题:如何对上面的缺失值,用每列非缺失值的平均值,或者中位数填充?非常感谢!