Skip to content

Commit d98f25a

Browse files
Licht-Tjreback
authored andcommitted
BUG: Fix wrong khash method definition (#20966)
1 parent 2299693 commit d98f25a

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

doc/source/whatsnew/v0.23.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,7 @@ Indexing
12551255
- Bug in partial string indexing on a ``Series/DataFrame`` with a monotonic decreasing ``DatetimeIndex`` (:issue:`19362`)
12561256
- Bug in performing in-place operations on a ``DataFrame`` with a duplicate ``Index`` (:issue:`17105`)
12571257
- 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`)
1258+
- Bug in ``.loc`` with a ``uint64`` indexer (:issue:`20722`)
12581259

12591260
MultiIndex
12601261
^^^^^^^^^^

pandas/_libs/khash.pxd

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ cdef extern from "khash_python.h":
8484
kh_uint64_t* kh_init_uint64() nogil
8585
void kh_destroy_uint64(kh_uint64_t*) nogil
8686
void kh_clear_uint64(kh_uint64_t*) nogil
87-
khint_t kh_get_uint64(kh_uint64_t*, int64_t) nogil
87+
khint_t kh_get_uint64(kh_uint64_t*, uint64_t) nogil
8888
void kh_resize_uint64(kh_uint64_t*, khint_t) nogil
89-
khint_t kh_put_uint64(kh_uint64_t*, int64_t, int*) nogil
89+
khint_t kh_put_uint64(kh_uint64_t*, uint64_t, int*) nogil
9090
void kh_del_uint64(kh_uint64_t*, khint_t) nogil
9191

9292
bint kh_exist_uint64(kh_uint64_t*, khiter_t) nogil

pandas/tests/indexing/test_loc.py

+19
Original file line numberDiff line numberDiff line change
@@ -784,3 +784,22 @@ def convert_nested_indexer(indexer_type, keys):
784784
index=pd.MultiIndex.from_product(keys))
785785

786786
tm.assert_series_equal(result, expected)
787+
788+
def test_loc_uint64(self):
789+
# GH20722
790+
# Test whether loc accept uint64 max value as index.
791+
s = pd.Series([1, 2],
792+
index=[np.iinfo('uint64').max - 1,
793+
np.iinfo('uint64').max])
794+
795+
result = s.loc[np.iinfo('uint64').max - 1]
796+
expected = s.iloc[0]
797+
assert result == expected
798+
799+
result = s.loc[[np.iinfo('uint64').max - 1]]
800+
expected = s.iloc[[0]]
801+
tm.assert_series_equal(result, expected)
802+
803+
result = s.loc[[np.iinfo('uint64').max - 1,
804+
np.iinfo('uint64').max]]
805+
tm.assert_series_equal(result, s)

0 commit comments

Comments
 (0)