Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
Currently the pivot_table
has an aggfunc
parameter which is used to do a groupby aggregation here. However, no additional arguments can be passed into that agg
call. I'm specifically referring to the *args
which can be specified in (df/series) groupby.agg function. It would be very useful if pivot_table
could accept additional arguments for the aggfunc
.
Feature Description
I'm not 100% sure, but I think it would be something like this:
- Add a
**aggfunc_args
oraggfunc_args: dict
parameter to thepivot_table
function. - Do the same for the
__internal_pivot_table
function - Change the line here, from
agged = grouped.agg(aggfunc)
toagged = grouped.agg(aggfunc, **aggfunc_args)
. - Update the docs
Alternative Solutions
The same functionality can currently be achieved by specifying a custom function as aggfunc
, but using that is much slower. My use case is pretty much the same as this.
Instead of using pd.pivot_table(... , aggfunc=lambda x: x.sum(min_count=1))
, I would like to be able to do pd.pivot_table(... , aggfunc=sum, min_count=1)
or similiar.
Additional Context
No response