Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 8
    Note: you can also say something like for row in df[['c1','c2']].itertuples(index=True, name=None): to include only certain columns in the row iterator. Commented Jun 29, 2018 at 7:29
  • I don't know why, but using name=None make itertuples 50% faster in my use case. Commented Dec 5, 2021 at 7:13
  • A raw for loop (my technique 2) is faster than iterrows() (my technique 1) as shown in my answer here. And itertuples() is 38x faster than iterrows(). In my "Rules of thumb" section in my answer, I propose that "[iterrows()] should never be used. [It is] super slow and [has] no advantages whatsoever." I present 13 techniques, several of which are extremely fast. iterrows() is the 2nd slowest. Commented Sep 10, 2024 at 15:48