File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -75,10 +75,10 @@ def summarize(
75
75
76
76
Summarize with a new column name:
77
77
78
- >>> df.summarize({"avg_run_2":df.avg_run.mean()})
78
+ >>> df.summarize({"avg_run_2":lambda df: df.avg_run.mean()})
79
79
avg_run_2
80
80
0 2.833333
81
- >>> df.summarize({"avg_run_2":lambda f: f.avg_run.mean(), by=['combine_id', 'category'])
81
+ >>> df.summarize({"avg_run_2":lambda f: f.avg_run.mean()} , by=['combine_id', 'category'])
82
82
avg_run_2
83
83
combine_id category
84
84
100200 heats 3.5
@@ -162,6 +162,8 @@ def summarize(
162
162
if isinstance (arg , dict ):
163
163
for col , func in arg .items ():
164
164
val = grp if by_is_true else df
165
+ if isinstance (func , str ):
166
+ val = val [col ]
165
167
try :
166
168
outcome = val .agg (func )
167
169
except (ValueError , AttributeError ):
You can’t perform that action at this time.
0 commit comments