Skip to content

REGR: maybe_convert_objects ignoring uints #47475

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

Merged
merged 11 commits into from
Jul 10, 2022

Conversation

rhshadrach
Copy link
Member

@rhshadrach rhshadrach commented Jun 22, 2022

I think this is closely related to #37258, though it does not impact any code examples there.

cc @TomAugspurger, @jbrockmendel, @jorisvandenbossche

@rhshadrach rhshadrach added Bug Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version labels Jun 22, 2022
"""
return PyObject_TypeCheck(obj, &PySignedIntegerArrType_Type)

cdef inline bint is_uinteger_object(object obj) nogil:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you expect these to be used elsewhere? if not, i think the build might be marginally faster (maybe even smaller) if they go directly in lib.pyx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd hazard a guess no. Also, I had reservations on the is_sinteger_object function anyways; it would return False even if e.g. -1 is passed, which is possibly the wrong answer depending on use. But every other function there only looked at the type of object, so it seemed wrong to add a function with value-dependent behavior. Inlining these gets around that.

@jreback jreback added this to the 1.5 milestone Jul 3, 2022
…16_regr

� Conflicts:
�	doc/source/whatsnew/v1.5.0.rst
[np.uint64(1)],
],
)
def test_constructor_numpy_uints(self, values):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are pd.Index or pd.array affected? pd.NumericIndex?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pd.array and pd.NumericIndex are not impacted; I've added tests for Index.

arr = pd.array([np.uint16(1)])
print(arr)

# <IntegerArray>
# [1]
# Length: 1, dtype: Int64

index = NumericIndex([np.uint16(1)])
print(index)

# NumericIndex([1], dtype='uint16')

Both of these are the same as 1.4.3

@jreback jreback merged commit 03af0ac into pandas-dev:main Jul 10, 2022
@jreback
Copy link
Contributor

jreback commented Jul 10, 2022

thanks @rhshadrach

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 Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: uint16 inserted as int16 when assigning row with dict
4 participants