Skip to content

API: downcating on fillna no-ops intentional? #45423

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
jbrockmendel opened this issue Jan 17, 2022 · 3 comments
Closed

API: downcating on fillna no-ops intentional? #45423

jbrockmendel opened this issue Jan 17, 2022 · 3 comments
Labels
API - Consistency Internal Consistency of API/Behavior Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Jan 17, 2022

ser = pd.Series([1, 2, 3], dtype=object)

>>> ser.fillna(4).dtype
dtype('int64')

Better to retain dtype in these cases?

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 17, 2022
@jreback
Copy link
Contributor

jreback commented Jan 17, 2022

this was the point of the downcast kw

as we normally will cast object if possible

@jorisvandenbossche
Copy link
Member

IMO we shouldn't retain or not retain dtype based on whether it was in practice a no-op or not. In which case the discussion is about downcasting in general, like:

In [31]: ser = pd.Series([1, 2, 3, np.nan], dtype=object)

In [32]: ser.fillna(4)
Out[32]: 
0    1
1    2
2    3
3    4
dtype: int64

@jreback jreback added this to the 1.5 milestone Feb 1, 2022
@jreback jreback added API - Consistency Internal Consistency of API/Behavior 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 Feb 1, 2022
@jbrockmendel
Copy link
Member Author

closed by #45673

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

No branches or pull requests

3 participants