File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -156,14 +156,14 @@ def summarize(
156
156
for col , func in arg .items ():
157
157
val = grp if by_is_true else df
158
158
if isinstance (func , str ):
159
- val = val [col ]
159
+ outcome = val [col ]. agg ( func )
160
160
elif is_scalar (func ):
161
- aggs [ col ] = func
162
- break
163
- try :
164
- outcome = val .agg (func )
165
- except (ValueError , AttributeError ):
166
- outcome = func (val )
161
+ outcome = func
162
+ else :
163
+ try :
164
+ outcome = val .agg (func )
165
+ except (ValueError , AttributeError ):
166
+ outcome = func (val )
167
167
aggs [col ] = outcome
168
168
else :
169
169
columns , func , names = SD (* arg )
@@ -205,10 +205,13 @@ def summarize(
205
205
name = f"{ col } { name } "
206
206
else :
207
207
name = col
208
- try :
208
+ if isinstance ( funcn , str ) :
209
209
outcome = val .agg (funcn )
210
- except (ValueError , AttributeError ):
211
- outcome = funcn (val )
210
+ else :
211
+ try :
212
+ outcome = val .agg (funcn )
213
+ except (ValueError , AttributeError ):
214
+ outcome = funcn (val )
212
215
aggs [name ] = outcome
213
216
aggs = {
214
217
col : [outcome ] if is_scalar (outcome ) else outcome
You can’t perform that action at this time.
0 commit comments