How to make your Pandas operation 100x faster | by Yifei Huang | Dec, 2020

[ad_1]


A practical guide to speeding up your Pandas code

Yifei Huang
Photo by Matthew Brodeur on Unsplash
image by author
[sum_square(row[0], row[1]) for _, row in df.iterrows()]
[sum_square(a, b) for a, b in df[[0, 1]].itertuples(index=False)]
df.apply(lambda row: sum_square(row[0], row[1]), axis=1 )
df.apply(lambda row: sum_square(row[0], row[1]), raw=True, axis=1 )
np.vectorize(sum_square)(df[0], df[1])
np.power(df[0] + df[1], 2)
image by author

Read More …

[ad_2]


Write a comment