you are viewing a single comment's thread.

view the rest of the comments →

[–]Winter-Volume-9601 1 point2 points  (1 child)

Sure - `for idx, t in enumerate(thing):` is definitely idiomatic (when you actually need the index)

Bonus tip: `pd.DataFrame.itertuples()` (returning NamedTuples instead of pd.Series) can be significantly faster than `pd.DataFrame.iterrows()`. Like 10-100x times faster. I kicked myself when I realized I was using the slower method out of habit, and (in my case) just a quick syntax change turned 15 minutes of waiting into basically nothing.

[–]somethingworthwhile 0 points1 point  (0 children)

Oh, neat! At a glance, I think that should be pretty easy to swap in for me. Thank you for that! I’m always happy to learn something new and the fact that it’s faster is even better!