I have the following dataset for which I want to calculate several aggregation metrics>
For some I'm using the standard functions, but for other I relay on the
I get and error since it has two parameters, x and lag by I'm only passing the x implicitly in the groupby.
How can I specify the other parameters required?
CodePudding user response:
see the pandas.DataFrameGroupBy.aggregate
docs. Additional keyword arguments are passed to the function. So you can do this:
sample.groupby('id').agg(
['std', benford_correlation,absolute_maximum],
additional_arg=value,
)
but if you need to pass different arguments to each function, you could use a lambda function:
sample.groupby('id').agg(
[
'std',
lambda s: benford_correlation(s, lag=1),
absolute_maximum,
],
)