Closed
Description
from SO: https://groups.google.com/forum/#!topic/pydata/C8VoV4do7io
need to catch errors on the putmask and skip that block (returning it unchanged)
In [9]: df = DataFrame(dict(A = np.random.randn(3),B=date_range('20130101',periods=3),C=['foo','bar','bah'],D=['foo2','bar2','bah2']),index=date_range('20130110',periods=3))
In [10]: df
Out[10]:
A B C D
2013-01-10 -2.002643 2013-01-01 foo foo2
2013-01-11 1.897382 2013-01-02 bar bar2
2013-01-12 0.038903 2013-01-03 bah bah2
[3 rows x 4 columns]
In [11]: df.iloc[2,[0,2,3]] = np.nan
In [12]: df
Out[12]:
A B C D
2013-01-10 -2.002643 2013-01-01 foo foo2
2013-01-11 1.897382 2013-01-02 bar bar2
2013-01-12 NaN 2013-01-03 NaN NaN
[3 rows x 4 columns]
In [13]: df.fillna(-1)
Out[13]:
A B C D
2013-01-10 -2.002643 2013-01-01 foo foo2
2013-01-11 1.897382 2013-01-02 bar bar2
2013-01-12 -1.000000 2013-01-03 -1 -1
[3 rows x 4 columns]
In [14]: df.fillna('?')
ValueError: Error parsing datetime string "?" at position 0
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
[-]BUG: fillna with invalid valid for a column type[/-][+]BUG: fillna with invalid value for a block type[/+]terrytangyuan commentedon Sep 11, 2015
So does this mean in
fillna
,nan
's cannot be replaced by non-numeric types? Any suggestions on how to go for this?