@@ -132,6 +132,9 @@ def pinner(cls):
132
132
class SeriesGroupBy (GroupBy ):
133
133
_apply_whitelist = base .series_apply_whitelist
134
134
135
+ def _iterate_slices (self ):
136
+ yield self ._selection_name , self ._selected_obj
137
+
135
138
@property
136
139
def _selection_name (self ):
137
140
"""
@@ -323,7 +326,7 @@ def _aggregate_multiple_funcs(self, arg, _level):
323
326
324
327
return DataFrame (results , columns = columns )
325
328
326
- def _wrap_output (self , output , index , names = None ):
329
+ def _wrap_series_output (self , output , index , names = None ):
327
330
""" common agg/transform wrapping logic """
328
331
output = output [self ._selection_name ]
329
332
@@ -336,13 +339,15 @@ def _wrap_output(self, output, index, names=None):
336
339
return Series (output , index = index , name = name )
337
340
338
341
def _wrap_aggregated_output (self , output , names = None ):
339
- result = self ._wrap_output (
342
+ result = self ._wrap_series_output (
340
343
output = output , index = self .grouper .result_index , names = names
341
344
)
342
345
return self ._reindex_output (result )._convert (datetime = True )
343
346
344
347
def _wrap_transformed_output (self , output , names = None ):
345
- return self ._wrap_output (output = output , index = self .obj .index , names = names )
348
+ return self ._wrap_series_output (
349
+ output = output , index = self .obj .index , names = names
350
+ )
346
351
347
352
def _wrap_applied_output (self , keys , values , not_indexed_same = False ):
348
353
if len (keys ) == 0 :
@@ -866,7 +871,7 @@ def aggregate(self, func=None, *args, **kwargs):
866
871
if self .grouper .nkeys > 1 :
867
872
return self ._python_agg_general (func , * args , ** kwargs )
868
873
elif args or kwargs :
869
- result = self ._aggregate_generic (func , * args , ** kwargs )
874
+ result = self ._aggregate_frame (func , * args , ** kwargs )
870
875
else :
871
876
872
877
# try to treat as if we are passing a list
@@ -875,7 +880,7 @@ def aggregate(self, func=None, *args, **kwargs):
875
880
[func ], _level = _level , _axis = self .axis
876
881
)
877
882
except Exception :
878
- result = self ._aggregate_generic (func )
883
+ result = self ._aggregate_frame (func )
879
884
else :
880
885
result .columns = Index (
881
886
result .columns .levels [0 ], name = self ._selected_obj .columns .name
@@ -999,7 +1004,7 @@ def _cython_agg_blocks(self, how, alt=None, numeric_only=True, min_count=-1):
999
1004
1000
1005
return new_items , new_blocks
1001
1006
1002
- def _aggregate_generic (self , func , * args , ** kwargs ):
1007
+ def _aggregate_frame (self , func , * args , ** kwargs ):
1003
1008
if self .grouper .nkeys != 1 :
1004
1009
raise AssertionError ("Number of keys must be 1" )
1005
1010
@@ -1022,7 +1027,7 @@ def _aggregate_generic(self, func, *args, **kwargs):
1022
1027
wrapper = lambda x : func (x , * args , ** kwargs )
1023
1028
result [name ] = data .apply (wrapper , axis = axis )
1024
1029
1025
- return self ._wrap_generic_output (result , obj )
1030
+ return self ._wrap_frame_output (result , obj )
1026
1031
1027
1032
def _aggregate_item_by_item (self , func , * args , ** kwargs ):
1028
1033
# only for axis==0
@@ -1506,7 +1511,7 @@ def _gotitem(self, key, ndim, subset=None):
1506
1511
1507
1512
raise AssertionError ("invalid ndim for _gotitem" )
1508
1513
1509
- def _wrap_generic_output (self , result , obj ):
1514
+ def _wrap_frame_output (self , result , obj ):
1510
1515
result_index = self .grouper .levels [0 ]
1511
1516
1512
1517
if self .axis == 0 :
0 commit comments