I would like to use df.groupby()
in combination with apply()
to apply a function to each row per group.
I normally use the following code, which usually works (note, that this is without groupby()
):
df.apply(myFunction, args=(arg1,))
With the groupby()
I tried the following:
df.groupby('columnName').apply(myFunction, args=(arg1,))
However, I get the following error:
TypeError: myFunction() got an unexpected keyword argument 'args'
Hence, my question is: How can I use groupby()
and apply()
with a function that needs arguments?