6868 infer_dtype_from_object ,
6969 is_bool_dtype ,
7070 is_datetime64_any_dtype ,
71- is_datetime64tz_dtype ,
7271 is_dict_like ,
7372 is_dtype_equal ,
7473 is_extension_array_dtype ,
@@ -7784,20 +7783,9 @@ def _reduce(
77847783 def f (x ):
77857784 return op (x , axis = axis , skipna = skipna , ** kwds )
77867785
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-
77987786 if numeric_only is None :
7787+ values = self .values
77997788 try :
7800- values = self .values
78017789 result = f (values )
78027790
78037791 if filter_type == "bool" and is_object_dtype (values ) and axis is None :
@@ -7809,27 +7797,23 @@ def f(x):
78097797
78107798 # try by-column first
78117799 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
78337817
78347818 if filter_type is None or filter_type == "numeric" :
78357819 data = self ._get_numeric_data ()
0 commit comments