Skip to content

Commit 7f752d5

Browse files
committed
fix attribute error in NamedAgg
1 parent 240cc96 commit 7f752d5

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

pandas/core/groupby/generic.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,9 @@ class NamedAgg(_BaseNamedAgg):
143143
"""
144144

145145
def __new__(cls, column, aggfunc, *args, **kwargs):
146-
original_aggfunc = aggfunc
147146
if not isinstance(aggfunc, str):
148147
aggfunc = cls._get_wrapped_aggfunc(aggfunc, *args, **kwargs)
149-
150148
self = _BaseNamedAgg.__new__(cls, column, aggfunc)
151-
self.original_aggfunc = original_aggfunc
152149
return self
153150

154151
@staticmethod
@@ -161,7 +158,7 @@ def wrapped_aggfunc(*new_args, **new_kwargs):
161158
return wrapped_aggfunc
162159

163160
def __repr__(self):
164-
return f"NamedAgg(column='{self.column}', aggfunc={self.original_aggfunc})"
161+
return f"NamedAgg(column='{self.column}', aggfunc={self.aggfunc})"
165162

166163

167164
class SeriesGroupBy(GroupBy[Series]):

0 commit comments

Comments
 (0)