I would like to apply a function with argument to a pandas series: I have found two different solution of SO:
python pandas: apply a function with arguments to a series
and
Passing multiple arguments to apply (Python)
both of them rely on the use of functool.partial
and they works absolutely fine. By the way the new version of Pandas support multiple argument: in any case I do not understand how does it works. Example:
a=pd.DataFrame({'x':[1,2],'y':[10,20]})
a['x'].apply(lambda x,y: x+y, args=(100))
It exits with a:
TypeError: <lambda>() argument after * must be a sequence, not int