Skip to content

BUG: Fix wrong khash method definition #20966

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,7 @@ Indexing
- Bug in ``.loc`` assignment with a single-element list-like incorrectly assigns as a list (:issue:`19474`)
- Bug in partial string indexing on a ``Series/DataFrame`` with a monotonic decreasing ``DatetimeIndex`` (:issue:`19362`)
- Bug in :meth:`IntervalIndex.get_loc` and :meth:`IntervalIndex.get_indexer` when used with an :class:`IntervalIndex` containing a single interval (:issue:`17284`, :issue:`20921`)
- Bug in ``.loc`` with a ``uint64`` indexer (:issue:`20722`)

MultiIndex
^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/khash.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ cdef extern from "khash_python.h":
kh_uint64_t* kh_init_uint64() nogil
void kh_destroy_uint64(kh_uint64_t*) nogil
void kh_clear_uint64(kh_uint64_t*) nogil
khint_t kh_get_uint64(kh_uint64_t*, int64_t) nogil
khint_t kh_get_uint64(kh_uint64_t*, uint64_t) nogil
void kh_resize_uint64(kh_uint64_t*, khint_t) nogil
khint_t kh_put_uint64(kh_uint64_t*, int64_t, int*) nogil
khint_t kh_put_uint64(kh_uint64_t*, uint64_t, int*) nogil
void kh_del_uint64(kh_uint64_t*, khint_t) nogil

bint kh_exist_uint64(kh_uint64_t*, khiter_t) nogil
Expand Down
19 changes: 19 additions & 0 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,3 +784,22 @@ def convert_nested_indexer(indexer_type, keys):
index=pd.MultiIndex.from_product(keys))

tm.assert_series_equal(result, expected)

def test_loc_uint64(self):
# GH20722
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a 1 line comment about what this is about

# Test whether loc accept uint64 max value as index.
s = pd.Series([1, 2],
index=[np.iinfo('uint64').max - 1,
np.iinfo('uint64').max])

result = s.loc[np.iinfo('uint64').max - 1]
expected = s.iloc[0]
assert result == expected

result = s.loc[[np.iinfo('uint64').max - 1]]
expected = s.iloc[[0]]
tm.assert_series_equal(result, expected)

result = s.loc[[np.iinfo('uint64').max - 1,
np.iinfo('uint64').max]]
tm.assert_series_equal(result, s)