The import numpy as np
The import pandas as pd
The from numpy import nan as NA
X=pd. DataFrame (np) arange (15). Reshape (5, 3), the index=list (' defgh '), the columns=list (' ABC '))
X.l oc [' e ']=None
X.l oc [' f ', 'b']=None
The results are as follows:
The 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
Rookie question: how to missing value, average value of each column is not missing, or the median fill? Thank you very much!
CodePudding user response:
Pandas have a fillCodePudding user response:
X.f illna (x.m ean) to fill the averageX.f illna (x. median) in the median