Last active
May 11, 2019 14:16
-
-
Save kujjwal02/71405d233b975da6cef5aafd57065183 to your computer and use it in GitHub Desktop.
Parallel apply pandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://towardsdatascience.com/make-your-own-super-pandas-using-multiproc-1c04f41944a1 | |
def parallelize_dataframe(df, func, n_cores=4): | |
df_split = np.array_split(df, n_cores) | |
pool = Pool(n_cores) | |
df = pd.concat(pool.map(func, df_split)) | |
pool.close() | |
pool.join() | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment