@@ -792,24 +792,6 @@ def count(self) -> Series:
792
792
)
793
793
return self ._reindex_output (result , fill_value = 0 )
794
794
795
- def pct_change (self , periods = 1 , fill_method = "pad" , limit = None , freq = None ):
796
- """Calculate pct_change of each value to previous entry in group"""
797
- # TODO: Remove this conditional when #23918 is fixed
798
- if freq :
799
- return self .apply (
800
- lambda x : x .pct_change (
801
- periods = periods , fill_method = fill_method , limit = limit , freq = freq
802
- )
803
- )
804
- if fill_method is None : # GH30463
805
- fill_method = "pad"
806
- limit = 0
807
- filled = getattr (self , fill_method )(limit = limit )
808
- fill_grp = filled .groupby (self .grouper .codes )
809
- shifted = fill_grp .shift (periods = periods , freq = freq )
810
-
811
- return (filled / shifted ) - 1
812
-
813
795
@doc (Series .nlargest )
814
796
def nlargest (self , n : int = 5 , keep : str = "first" ):
815
797
f = partial (Series .nlargest , n = n , keep = keep )
@@ -1086,14 +1068,10 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame:
1086
1068
# test_resample_apply_product
1087
1069
1088
1070
obj = self ._obj_with_exclusions
1089
- result : dict [int | str , NDFrame ] = {}
1090
- for i , item in enumerate (obj ):
1091
- ser = obj .iloc [:, i ]
1092
- colg = SeriesGroupBy (
1093
- ser , selection = item , grouper = self .grouper , exclusions = self .exclusions
1094
- )
1071
+ result : dict [int , NDFrame ] = {}
1095
1072
1096
- result [i ] = colg .aggregate (func , * args , ** kwargs )
1073
+ for i , (item , sgb ) in enumerate (self ._iterate_column_groupbys (obj )):
1074
+ result [i ] = sgb .aggregate (func , * args , ** kwargs )
1097
1075
1098
1076
res_df = self .obj ._constructor (result )
1099
1077
res_df .columns = obj .columns
@@ -1368,14 +1346,7 @@ def _transform_item_by_item(self, obj: DataFrame, wrapper) -> DataFrame:
1368
1346
# gets here with non-unique columns
1369
1347
output = {}
1370
1348
inds = []
1371
- for i , col in enumerate (obj ):
1372
- subset = obj .iloc [:, i ]
1373
- sgb = SeriesGroupBy (
1374
- subset ,
1375
- selection = col ,
1376
- grouper = self .grouper ,
1377
- exclusions = self .exclusions ,
1378
- )
1349
+ for i , (colname , sgb ) in enumerate (self ._iterate_column_groupbys (obj )):
1379
1350
try :
1380
1351
output [i ] = sgb .transform (wrapper )
1381
1352
except TypeError :
0 commit comments