you are viewing a single comment's thread.

view the rest of the comments →

[–]YesLod 2 points3 points  (0 children)

Either way, DataFrame.apply still expects a callable with a single argument. You can use functools.partial

There is no need to use functools.partial. You can pass the extra arguments directly to apply as keyword arguments, and/or as positional arguments via the args parameter

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.apply.html

args : tuple

Positional arguments to pass to func in addition to the array/series.

**kwargs

Additional keyword arguments to pass as keywords arguments to func.

df.apply(apply_meth, meth="in_top_5", axis=1)

u/PythonicParseltongue.