Skip to content

Commit 792ef9c

Browse files
jbrockmendelyeshsurya
authored andcommitted
CLN: remove ensure_int_or_float (pandas-dev#41011)
1 parent 7ad4033 commit 792ef9c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/core/groupby/ops.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from pandas.core.dtypes.common import (
4444
ensure_float64,
4545
ensure_int64,
46-
ensure_int_or_float,
4746
ensure_platform_int,
4847
is_bool_dtype,
4948
is_categorical_dtype,
@@ -582,7 +581,7 @@ def _ea_wrap_cython_operation(
582581

583582
elif is_integer_dtype(values.dtype) or is_bool_dtype(values.dtype):
584583
# IntegerArray or BooleanArray
585-
values = ensure_int_or_float(values)
584+
values = values.to_numpy("float64", na_value=np.nan)
586585
res_values = self._cython_operation(
587586
kind, values, how, axis, min_count, **kwargs
588587
)
@@ -660,9 +659,11 @@ def _cython_operation(
660659
values = values.view("int64")
661660
is_numeric = True
662661
elif is_bool_dtype(dtype):
663-
values = ensure_int_or_float(values)
662+
values = values.astype("int64")
664663
elif is_integer_dtype(dtype):
665-
values = ensure_int_or_float(values)
664+
# e.g. uint8 -> uint64, int16 -> int64
665+
dtype = dtype.kind + "8"
666+
values = values.astype(dtype, copy=False)
666667
elif is_numeric:
667668
if not is_complex_dtype(dtype):
668669
values = ensure_float64(values)

0 commit comments

Comments
 (0)