Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

jreback opened this issue May 10, 2014 · 1 comment
Labels
Bug Internals Related to non-user accessible pandas implementation Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@jreback
Copy link
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 jreback added this to the 0.14.0 milestone May 10, 2014
@jreback jreback changed the title BUG: fillna with invalid valid for a column type BUG: fillna with invalid value for a block type May 10, 2014
@jreback jreback modified the milestones: 0.14.1, 0.14.0 May 11, 2014
@jreback jreback modified the milestones: 0.15.0, 0.14.1 Jun 26, 2014
@jreback jreback modified the milestones: 0.15.0, 0.15.1 Jul 6, 2014
@jreback jreback modified the milestones: 0.15.1, 0.15.0 Sep 4, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@terrytangyuan
Copy link
Contributor

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 milestones: 0.17.0, Next Major Release Sep 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Internals Related to non-user accessible pandas implementation Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

No branches or pull requests

2 participants