Skip to content

Commit

Permalink
CLN: remove ensure_int_or_float (pandas-dev#41011)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and yeshsurya committed May 6, 2021
1 parent 7ad4033 commit 792ef9c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pandas/core/groupby/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from pandas.core.dtypes.common import (
ensure_float64,
ensure_int64,
ensure_int_or_float,
ensure_platform_int,
is_bool_dtype,
is_categorical_dtype,
Expand Down Expand Up @@ -582,7 +581,7 @@ def _ea_wrap_cython_operation(

elif is_integer_dtype(values.dtype) or is_bool_dtype(values.dtype):
# IntegerArray or BooleanArray
values = ensure_int_or_float(values)
values = values.to_numpy("float64", na_value=np.nan)
res_values = self._cython_operation(
kind, values, how, axis, min_count, **kwargs
)
Expand Down Expand Up @@ -660,9 +659,11 @@ def _cython_operation(
values = values.view("int64")
is_numeric = True
elif is_bool_dtype(dtype):
values = ensure_int_or_float(values)
values = values.astype("int64")
elif is_integer_dtype(dtype):
values = ensure_int_or_float(values)
# e.g. uint8 -> uint64, int16 -> int64
dtype = dtype.kind + "8"
values = values.astype(dtype, copy=False)
elif is_numeric:
if not is_complex_dtype(dtype):
values = ensure_float64(values)
Expand Down

0 comments on commit 792ef9c

Please sign in to comment.