Skip to content

Int32Dtype will error when filling float values with the function fillna() #49954

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
1 task done
Reggieharden opened this issue Nov 29, 2022 · 4 comments
Closed
1 task done
Labels
Docs Needs Info Clarification about behavior needed to assess issue Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@Reggieharden
Copy link

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.Series.fillna.html?highlight=fillna#pandas.Series.fillna

https://pandas.pydata.org/docs/reference/api/pandas.Int32Dtype.html?highlight=int32#pandas.Int32Dtype

Documentation problem

version 1.3.5: cannot safely cast non-equivalent float64 to Int32

version 1.5.2 : Invalid value '1.1' for dtype Int32

Suggested fix for documentation

IntDtype automatically converts to float

@Reggieharden Reggieharden added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 29, 2022
@phofl
Copy link
Member

phofl commented Nov 29, 2022

Hi, thanks for your report. Do you wish for this to work or should we adjust the documentation?

This errors on purpose, so is not considered a bug.

@phofl phofl added the Needs Info Clarification about behavior needed to assess issue label Nov 30, 2022
@rhshadrach
Copy link
Member

There is an inconsistency here with other dtypes; float64 will coerce to object:

ser = Series([1, 2, np.nan])
print(ser.fillna('x'))
# 0    1.0
# 1    2.0
# 2      x
# dtype: object

@phofl
Copy link
Member

phofl commented Dec 8, 2022

Numpy dtypes upcast while our own nullable dtypes raise when setting incompatible values

@phofl
Copy link
Member

phofl commented Dec 9, 2022

Duplicate of #44289

@phofl phofl marked this as a duplicate of #44289 Dec 9, 2022
@phofl phofl closed this as completed Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Needs Info Clarification about behavior needed to assess issue Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

3 participants