68
68
infer_dtype_from_object ,
69
69
is_bool_dtype ,
70
70
is_datetime64_any_dtype ,
71
- is_datetime64tz_dtype ,
72
71
is_dict_like ,
73
72
is_dtype_equal ,
74
73
is_extension_array_dtype ,
@@ -7784,20 +7783,9 @@ def _reduce(
7784
7783
def f (x ):
7785
7784
return op (x , axis = axis , skipna = skipna , ** kwds )
7786
7785
7787
- # exclude timedelta/datetime unless we are uniform types
7788
- if (
7789
- axis == 1
7790
- and self ._is_datelike_mixed_type
7791
- and (
7792
- not self ._is_homogeneous_type
7793
- and not is_datetime64tz_dtype (self .dtypes [0 ])
7794
- )
7795
- ):
7796
- numeric_only = True
7797
-
7798
7786
if numeric_only is None :
7787
+ values = self .values
7799
7788
try :
7800
- values = self .values
7801
7789
result = f (values )
7802
7790
7803
7791
if filter_type == "bool" and is_object_dtype (values ) and axis is None :
@@ -7809,27 +7797,23 @@ def f(x):
7809
7797
7810
7798
# try by-column first
7811
7799
if filter_type is None and axis == 0 :
7812
- try :
7813
-
7814
- # this can end up with a non-reduction
7815
- # but not always. if the types are mixed
7816
- # with datelike then need to make sure a series
7817
-
7818
- # we only end up here if we have not specified
7819
- # numeric_only and yet we have tried a
7820
- # column-by-column reduction, where we have mixed type.
7821
- # So let's just do what we can
7822
- from pandas .core .apply import frame_apply
7823
-
7824
- opa = frame_apply (
7825
- self , func = f , result_type = "expand" , ignore_failures = True
7826
- )
7827
- result = opa .get_result ()
7828
- if result .ndim == self .ndim :
7829
- result = result .iloc [0 ]
7830
- return result
7831
- except Exception :
7832
- pass
7800
+ # this can end up with a non-reduction
7801
+ # but not always. if the types are mixed
7802
+ # with datelike then need to make sure a series
7803
+
7804
+ # we only end up here if we have not specified
7805
+ # numeric_only and yet we have tried a
7806
+ # column-by-column reduction, where we have mixed type.
7807
+ # So let's just do what we can
7808
+ from pandas .core .apply import frame_apply
7809
+
7810
+ opa = frame_apply (
7811
+ self , func = f , result_type = "expand" , ignore_failures = True
7812
+ )
7813
+ result = opa .get_result ()
7814
+ if result .ndim == self .ndim :
7815
+ result = result .iloc [0 ]
7816
+ return result
7833
7817
7834
7818
if filter_type is None or filter_type == "numeric" :
7835
7819
data = self ._get_numeric_data ()
0 commit comments