Pandas fillna doesn't work
I have a dataframe with nans in it:
>>>df.head()
Out[1]:
JPM US SMALLER COMPANIES C ACC
1990-01-02 NaN
1990-01-03 NaN
1990-01-04 NaN
1990-01-05 NaN
1990-01-08 NaN
I have another dataframe with values ββin it:
>>>t.head()
Out[1]:
1990-01-02 51.95
1990-01-03 52.63
1990-01-04 53.04
1990-01-05 52.07
1990-01-08 51.73
Name: JPM US SMALLER COMPANIES C ACC, dtype: float64
Unfortunately df.fillna doesn't seem to work for me:
>>>df.fillna( t ).head()
Out[1]:
JPM US SMALLER COMPANIES C ACC
1990-01-02 NaN
1990-01-03 NaN
1990-01-04 NaN
1990-01-05 NaN
1990-01-08 NaN
[5 rows x 1 columns]
Why is this happening? I am on pandas 0.13.1
+7
Ginger
source
to share
2 answers
you need inplace
df[1].fillna(0, inplace=True)
+33
zinking
source
to share
You need to assign a value df = df.fillna( t )
0
Ravikant singh
source
to share