5 ms·
How NOT to write pandas code
- applecrazy 7y agoThe title is a bit clickbaity, so here’s a TL;DR: Try to use the built-in vectorized Pandas functions instead of writing explicit loops.
- Icathian 7y agoIt's wild how much faster iterrows and itertuples are. I wish I'd known a year ago. This is one of those cases that really isn't just pedantic, "pythonic", nagging. It matters.
- s_r_n 7y agoI've never seen a Pandas tutorial advocating the for-loops the author describes and I have rarely come across for-loops in other people's Pandas code. I think the article could remove the for-loop "how not to" examples and it would be a typical "getting started with Pandas" article.
- thehappypm 7y agoObviously nobody would advocate for them. But for a new Pandas programmer, loops are incredibly obvious, familiar, and do work. So, tons of people use them.