Skip to content

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

Closed
@jreback

Description

@jreback
Contributor

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

Activity

added this to the 0.14.0 milestone on May 10, 2014
changed the title [-]BUG: fillna with invalid valid for a column type[/-] [+]BUG: fillna with invalid value for a block type[/+] on May 10, 2014
modified the milestones: 0.14.1, 0.14.0 on May 11, 2014
modified the milestones: 0.15.0, 0.14.1 on Jun 26, 2014
modified the milestones: 0.15.0, 0.15.1 on Jul 6, 2014
modified the milestones: 0.15.1, 0.15.0 on Sep 4, 2014
modified the milestones: 0.16.0, Next Major Release on Mar 6, 2015
terrytangyuan

terrytangyuan commented on Sep 11, 2015

@terrytangyuan
Contributor

So does this mean in fillna, nan's cannot be replaced by non-numeric types? Any suggestions on how to go for this?

modified the milestones: 0.17.0, Next Major Release on Sep 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugInternalsRelated to non-user accessible pandas implementationMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jreback@terrytangyuan

        Issue actions

          BUG: fillna with invalid value for a block type · Issue #7095 · pandas-dev/pandas