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/API: Series[object].fillna ignores downcast=None, "infer" #44241

Closed
3 tasks done
jbrockmendel opened this issue Oct 30, 2021 · 0 comments · Fixed by #45062
Closed
3 tasks done

BUG/API: Series[object].fillna ignores downcast=None, "infer" #44241

jbrockmendel opened this issue Oct 30, 2021 · 0 comments · Fixed by #45062
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Oct 30, 2021

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the master branch of pandas.

Reproducible Example

ser = pd.Series([True, None, False, True, None], dtype=object)
>>> ser.fillna(True, downcast=None)
0     True
1     True
2    False
3     True
4     True
dtype: bool

>>> ser.fillna(True, downcast="infer")
0     True
1     True
2    False
3     True
4     True
dtype: object

Issue Description

Note that downcast=None is the default, so this also happens with just ser.fillna(True).

Disabling the special-casing for object dtype in Block._maybe_downcast breaks 9 tests. I need to check, think there may be some EA cases that aren't tested but where behavior would change if removed that special-casing.

Expected Behavior

I'd expect it to go the other way, with object dtype retained with downcast=None and bool inferred with downcast="infer"

Installed Versions

Replace this line with the output of pd.show_versions()

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 30, 2021
@mroeschke mroeschke added Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 31, 2021
@jreback jreback added this to the 1.4 milestone Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants