fillna() 可以通过几种方式用非NA数据“填写”NA值,我们将说明:
用标量值替换NA
In [41]: df2
Out[41]:
one two three four five timestamp
a NaN 0.501113 -0.355322 bar False NaT
c NaN 0.580967 0.983801 bar False NaT
e 0.057802 0.761948 -0.712964 bar True 2012-01-01
f -0.443160 -0.974602 1.047704 bar False 2012-01-01
h NaN -1.053898 -0.019369 bar False NaT
In [42]: df2.fillna(0)
Out[42]:
one two three four five timestamp
a 0.000000 0.501113 -0.355322 bar False 0
c 0.000000 0.580967 0.983801 bar False 0
e 0.057802 0.761948 -0.712964 bar True 2012-01-01 00:00:00
f -0.443160 -0.974602 1.047704 bar False 2012-01-01 00:00:00
h 0.000000 -1.053898 -0.019369 bar False 0
In [43]: df2['one'].fillna('missing')
Out[43]:
a missing
c missing
e 0.057802
f -0.44316
h missing
Name: one, dtype: object








暂无数据