Skip to content

Commit 3602166

Browse files
author
samuel.oranyeli
committed
fix doctest failures
1 parent 912a29f commit 3602166

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

janitor/functions/summarize.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ def summarize(
7575
7676
Summarize with a new column name:
7777
78-
>>> df.summarize({"avg_run_2":df.avg_run.mean()})
78+
>>> df.summarize({"avg_run_2":lambda df: df.avg_run.mean()})
7979
avg_run_2
8080
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'])
8282
avg_run_2
8383
combine_id category
8484
100200 heats 3.5
@@ -162,6 +162,8 @@ def summarize(
162162
if isinstance(arg, dict):
163163
for col, func in arg.items():
164164
val = grp if by_is_true else df
165+
if isinstance(func, str):
166+
val = val[col]
165167
try:
166168
outcome = val.agg(func)
167169
except (ValueError, AttributeError):

0 commit comments

Comments
 (0)