File tree 2 files changed +6
-23
lines changed
2 files changed +6
-23
lines changed Original file line number Diff line number Diff line change @@ -610,10 +610,7 @@ def nunique(self, dropna: bool = True) -> Series:
610
610
611
611
@doc (Series .describe )
612
612
def describe (self , ** kwargs ):
613
- result = self .apply (lambda x : x .describe (** kwargs ))
614
- if self .axis == 1 :
615
- return result .T
616
- return result .unstack ()
613
+ return super ().describe (** kwargs )
617
614
618
615
def value_counts (
619
616
self ,
Original file line number Diff line number Diff line change @@ -2693,11 +2693,7 @@ def blk_func(values: ArrayLike) -> ArrayLike:
2693
2693
2694
2694
obj = self ._obj_with_exclusions
2695
2695
is_ser = obj .ndim == 1
2696
- if is_ser :
2697
- # i.e. SeriesGroupBy
2698
- mgr = obj .to_frame ()._mgr
2699
- else :
2700
- mgr = self ._get_data_to_aggregate ()
2696
+ mgr = self ._get_data_to_aggregate ()
2701
2697
2702
2698
res_mgr = mgr .grouped_reduce (blk_func , ignore_failures = True )
2703
2699
if len (res_mgr .items ) != len (mgr .items ):
@@ -3135,13 +3131,7 @@ def blk_func(values: ArrayLike) -> ArrayLike:
3135
3131
3136
3132
# Operate block-wise instead of column-by-column
3137
3133
orig_ndim = obj .ndim
3138
- if orig_ndim == 1 :
3139
- # Operate on DataFrame, then squeeze below
3140
- obj = obj .to_frame ()
3141
-
3142
- mgr = obj ._mgr
3143
- if self .axis == 1 :
3144
- mgr = obj .T ._mgr
3134
+ mgr = self ._get_data_to_aggregate ()
3145
3135
3146
3136
if numeric_only :
3147
3137
mgr = mgr .get_numeric_data ()
@@ -3168,14 +3158,10 @@ def blk_func(values: ArrayLike) -> ArrayLike:
3168
3158
# We should never get here
3169
3159
raise TypeError ("All columns were dropped in grouped_reduce" )
3170
3160
3171
- out = type (obj )(res_mgr )
3172
-
3173
3161
if orig_ndim == 1 :
3174
- assert out .ndim == 2
3175
- assert out .shape [1 ] == 1
3176
- out = out .iloc [:, 0 ]
3177
- # restore name=None in case to_frame set columns to [0]
3178
- out .name = self .obj .name
3162
+ out = self ._wrap_agged_manager (res_mgr )
3163
+ else :
3164
+ out = type (obj )(res_mgr )
3179
3165
3180
3166
return self ._wrap_aggregated_output (out )
3181
3167
You can’t perform that action at this time.
0 commit comments