pandas多进程加速apply
from pandarallel import pandarallel import pandas as pd pandarallel.initialize(nb_workers=4) res = pd.read_csv('./8.csv', low_memory=False) res['SFRZM'] = res['SFRZM'].parallel_apply(lambda x: str(x) + 'x') res.to_csv('./9.csv', index=False)
github地址: https://github.com/nalepae/pandarallel/
Without parallelization | With parallelization |
---|---|
df.apply(func) |
df.parallel_apply(func) |
df.applymap(func) |
df.parallel_applymap(func) |
df.groupby(args).apply(func) |
df.groupby(args).parallel_apply(func) |
df.groupby(args1).col_name.rolling(args2).apply(func) |
df.groupby(args1).col_name.rolling(args2).parallel_apply(func) |
df.groupby(args1).col_name.expanding(args2).apply(func) |
df.groupby(args1).col_name.expanding(args2).parallel_apply(func) |
series.map(func) |
series.parallel_map(func) |
series.apply(func) |
series.parallel_apply(func) |
series.rolling(args).apply(func) |
series.rolling(args).parallel_apply(func) |