Skip to content

Commit 045ddd7

Browse files
committed
BUG: Use value_count_uint64 in value_counts
1 parent b1d7499 commit 045ddd7

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pandas/core/algorithms.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
from pandas import compat, lib, tslib, _np_version_under1p8
1010
from pandas.types.cast import _maybe_promote
1111
from pandas.types.generic import ABCSeries, ABCIndex
12-
from pandas.types.common import (is_integer_dtype,
12+
from pandas.types.common import (is_unsigned_integer_dtype,
13+
is_signed_integer_dtype,
14+
is_integer_dtype,
1315
is_int64_dtype,
1416
is_categorical_dtype,
1517
is_extension_type,
@@ -471,9 +473,12 @@ def _value_counts_arraylike(values, dropna=True):
471473
if is_period_type:
472474
keys = PeriodIndex._simple_new(keys, freq=freq)
473475

474-
elif is_integer_dtype(dtype):
476+
elif is_signed_integer_dtype(dtype):
475477
values = _ensure_int64(values)
476478
keys, counts = htable.value_count_int64(values, dropna)
479+
elif is_unsigned_integer_dtype(dtype):
480+
values = _ensure_uint64(values)
481+
keys, counts = htable.value_count_uint64(values, dropna)
477482
elif is_float_dtype(dtype):
478483
values = _ensure_float64(values)
479484
keys, counts = htable.value_count_float64(values, dropna)

pandas/types/common.py

+12
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,18 @@ def is_integer_dtype(arr_or_dtype):
155155
not issubclass(tipo, (np.datetime64, np.timedelta64)))
156156

157157

158+
def is_signed_integer_dtype(arr_or_dtype):
159+
tipo = _get_dtype_type(arr_or_dtype)
160+
return (issubclass(tipo, np.signedinteger) and
161+
not issubclass(tipo, (np.datetime64, np.timedelta64)))
162+
163+
164+
def is_unsigned_integer_dtype(arr_or_dtype):
165+
tipo = _get_dtype_type(arr_or_dtype)
166+
return (issubclass(tipo, np.unsignedinteger) and
167+
not issubclass(tipo, (np.datetime64, np.timedelta64)))
168+
169+
158170
def is_int64_dtype(arr_or_dtype):
159171
tipo = _get_dtype_type(arr_or_dtype)
160172
return issubclass(tipo, np.int64)

0 commit comments

Comments
 (0)