BUG: fillna with invalid value for a block type #7095

Closed
jreback opened this Issue May 10, 2014 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

jreback commented May 10, 2014

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

jreback added this to the 0.14.0 milestone May 10, 2014

jreback changed the title from BUG: fillna with invalid valid for a column type to BUG: fillna with invalid value for a block type May 10, 2014

jreback added the Internals label May 10, 2014

@jreback jreback modified the milestone: 0.14.1, 0.14.0 May 11, 2014

@jreback jreback modified the milestone: 0.15.0, 0.14.1 Jun 26, 2014

@jreback jreback modified the milestone: 0.15.0, 0.15.1 Jul 6, 2014

@jreback jreback modified the milestone: 0.15.1, 0.15.0 Sep 4, 2014

@jreback jreback modified the milestone: 0.16.0, Next Major Release Mar 6, 2015

Contributor

terrytangyuan commented 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?

@jreback jreback modified the milestone: 0.17.0, Next Major Release Sep 20, 2015

jreback closed this in #11153 Sep 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment