Skip to content

Commit 5dd27ed

Browse files
authored
CLN: remove unreachable in Series._reduce (#31932)
1 parent ff05154 commit 5dd27ed

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

pandas/core/series.py

+5-29
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@
3434
ensure_platform_int,
3535
is_bool,
3636
is_categorical_dtype,
37-
is_datetime64_dtype,
3837
is_dict_like,
3938
is_extension_array_dtype,
4039
is_integer,
4140
is_iterator,
4241
is_list_like,
4342
is_object_dtype,
4443
is_scalar,
45-
is_timedelta64_dtype,
4644
)
4745
from pandas.core.dtypes.generic import (
4846
ABCDataFrame,
@@ -64,7 +62,7 @@
6462
from pandas.core import algorithms, base, generic, nanops, ops
6563
from pandas.core.accessor import CachedAccessor
6664
from pandas.core.arrays import ExtensionArray, try_cast_to_ea
67-
from pandas.core.arrays.categorical import Categorical, CategoricalAccessor
65+
from pandas.core.arrays.categorical import CategoricalAccessor
6866
from pandas.core.arrays.sparse import SparseAccessor
6967
import pandas.core.common as com
7068
from pandas.core.construction import (
@@ -3848,41 +3846,19 @@ def _reduce(
38483846
if axis is not None:
38493847
self._get_axis_number(axis)
38503848

3851-
if isinstance(delegate, Categorical):
3852-
return delegate._reduce(name, skipna=skipna, **kwds)
3853-
elif isinstance(delegate, ExtensionArray):
3849+
if isinstance(delegate, ExtensionArray):
38543850
# dispatch to ExtensionArray interface
38553851
return delegate._reduce(name, skipna=skipna, **kwds)
3856-
elif is_datetime64_dtype(delegate):
3857-
# use DatetimeIndex implementation to handle skipna correctly
3858-
delegate = DatetimeIndex(delegate)
3859-
elif is_timedelta64_dtype(delegate) and hasattr(TimedeltaIndex, name):
3860-
# use TimedeltaIndex to handle skipna correctly
3861-
# TODO: remove hasattr check after TimedeltaIndex has `std` method
3862-
delegate = TimedeltaIndex(delegate)
3863-
3864-
# dispatch to numpy arrays
3865-
elif isinstance(delegate, np.ndarray):
3852+
3853+
else:
3854+
# dispatch to numpy arrays
38663855
if numeric_only:
38673856
raise NotImplementedError(
38683857
f"Series.{name} does not implement numeric_only."
38693858
)
38703859
with np.errstate(all="ignore"):
38713860
return op(delegate, skipna=skipna, **kwds)
38723861

3873-
# TODO(EA) dispatch to Index
3874-
# remove once all internals extension types are
3875-
# moved to ExtensionArrays
3876-
return delegate._reduce(
3877-
op=op,
3878-
name=name,
3879-
axis=axis,
3880-
skipna=skipna,
3881-
numeric_only=numeric_only,
3882-
filter_type=filter_type,
3883-
**kwds,
3884-
)
3885-
38863862
def _reindex_indexer(self, new_index, indexer, copy):
38873863
if indexer is None:
38883864
if copy:

0 commit comments

Comments
 (0)