Skip to content

ensure_int_or_float Surprising Behavior with Int64 / ExtensionArrays #27506

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
WillAyd opened this issue Jul 21, 2019 · 0 comments · Fixed by #41011
Closed

ensure_int_or_float Surprising Behavior with Int64 / ExtensionArrays #27506

WillAyd opened this issue Jul 21, 2019 · 0 comments · Fixed by #41011
Labels
ExtensionArray Extending pandas with custom dtypes or arrays.
Milestone

Comments

@WillAyd
Copy link
Member

WillAyd commented Jul 21, 2019

Unearthed as part of #27424

>>> import pandas as pd
>>> from pandas.core.dtypes.common import ensure_int_or_float

>>> ensure_int_or_float(pd.Series(range(3), dtype='Int64'))
0    0
1    1
2    2
dtype: int64

# Directly against PandasArray now
>>> ensure_int_or_float(pd.Series(range(3), dtype='Int64').array)
array([0., 1., 2.])  # returns float

When the underlying array gets passed to ensure_int_or_float they don't return integer as expected. The issue here is due to the fact that the astype signature doesn't have casting as a parameter like other types going through ensure_int_or_float do

@WillAyd WillAyd added the ExtensionArray Extending pandas with custom dtypes or arrays. label Jul 21, 2019
@jreback jreback added this to the 1.3 milestone Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants