I want to apply some function on all pandas columns in parallel. For example, I want to do this in parallel:
def my_sum(x, a):
return x + a
df = pd.DataFrame({'num_legs': [2, 4, 8, 0],
'num_wings': [2, 0, 0, 0]})
df.apply(lambda x: my_sum(x, 2), axis=0)
I know there is a swifter package, but it doesn't support axis=0 in apply:
NotImplementedError: Swifter cannot perform axis=0 applies on large datasets. Dask currently does not have an axis=0 apply implemented. More details at https://github.com/jmcarpenter2/swifter/issues/10
Dask also doesn't support this for axis=0 (according to documentation in swifter).
I have googled several sources but couldn't find an easy solution.
Can't believe this is so complicated in pandas.