I want to apply a function with arguments to a series in python pandas:
x = my_series.apply(my_function, more_arguments_1)
y = my_series.apply(my_function, more_arguments_2)
...
The documentation describes support for an apply method, but it doesn't accept any arguments. Is there a different method that accepts arguments? Alternatively, am I missing a simple workaround?
Update (October 2017): Note that since this question was originally asked that pandas apply()
has been updated to handle positional and keyword arguments and the documentation link above now reflects that and shows how to include either type of argument.
functools.partial
, orstarmap
? – Joel CornettDataFrame.apply
docs andSeries.apply
docs – Martin Thoma