Skip to content

BUG: series.fillna() fails with quoted numbers #9043

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

Closed
wants to merge 1 commit into from

Conversation

jlowin
Copy link

@jlowin jlowin commented Dec 8, 2014

Here's a simple example:

import pandas as pd
import numpy as np

x = pd.Series(range(5))
x.iloc[1] = np.nan
x.fillna(0) # works
x.fillna('foo') # works
x.fillna('0') # crash

in the function _putmask_smart(), two numpy arrays are compared to determine if they have compatible dtypes. However if one array contains quoted numbers, then the test does NOT resolve as element wise compare, but rather as a "normal" python comparison. This means the result is False, rather than an array, and the attempt to get False.all() obviously fails.

Not sure exactly why the arrays don't compare as expected -- perhaps there are other criteria that would trigger it -- but an easy fix is to add AttributeError to the try/except clause as a "valid" error.

@jreback
Copy link
Contributor

jreback commented Dec 8, 2014

hmm, that is odd. Pls add a test for this.

@jreback jreback added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Dec 8, 2014
@jreback jreback added this to the 0.16.0 milestone Dec 8, 2014
@jreback
Copy link
Contributor

jreback commented Jan 18, 2015

@jlowin this needs a test and release note.

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 3, 2015
@jreback
Copy link
Contributor

jreback commented May 9, 2015

closing pls reopen if/when updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants