|
34 | 34 | ensure_platform_int, |
35 | 35 | is_bool, |
36 | 36 | is_categorical_dtype, |
37 | | - is_datetime64_dtype, |
38 | 37 | is_dict_like, |
39 | 38 | is_extension_array_dtype, |
40 | 39 | is_integer, |
41 | 40 | is_iterator, |
42 | 41 | is_list_like, |
43 | 42 | is_object_dtype, |
44 | 43 | is_scalar, |
45 | | - is_timedelta64_dtype, |
46 | 44 | ) |
47 | 45 | from pandas.core.dtypes.generic import ( |
48 | 46 | ABCDataFrame, |
|
64 | 62 | from pandas.core import algorithms, base, generic, nanops, ops |
65 | 63 | from pandas.core.accessor import CachedAccessor |
66 | 64 | 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 |
68 | 66 | from pandas.core.arrays.sparse import SparseAccessor |
69 | 67 | import pandas.core.common as com |
70 | 68 | from pandas.core.construction import ( |
@@ -3848,41 +3846,19 @@ def _reduce( |
3848 | 3846 | if axis is not None: |
3849 | 3847 | self._get_axis_number(axis) |
3850 | 3848 |
|
3851 | | - if isinstance(delegate, Categorical): |
3852 | | - return delegate._reduce(name, skipna=skipna, **kwds) |
3853 | | - elif isinstance(delegate, ExtensionArray): |
| 3849 | + if isinstance(delegate, ExtensionArray): |
3854 | 3850 | # dispatch to ExtensionArray interface |
3855 | 3851 | 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 |
3866 | 3855 | if numeric_only: |
3867 | 3856 | raise NotImplementedError( |
3868 | 3857 | f"Series.{name} does not implement numeric_only." |
3869 | 3858 | ) |
3870 | 3859 | with np.errstate(all="ignore"): |
3871 | 3860 | return op(delegate, skipna=skipna, **kwds) |
3872 | 3861 |
|
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 | | - |
3886 | 3862 | def _reindex_indexer(self, new_index, indexer, copy): |
3887 | 3863 | if indexer is None: |
3888 | 3864 | if copy: |
|
0 commit comments