How to change the starting index of iterrows()?

Each Answer to this Q is separated by one/two green lines.

We can use the following to iterate rows of a data frame.

for index, row in df.iterrows():

What if I want to begin from a different row index? (not from first row)?

i know this has an answer, but why not just do:

for i, r in df.iloc[1:].iterrows():

Try using itertools.islice

from itertools import islice

for index, row in islice(df.iterrows(), 1, None):

Sure:

for i,(index,row) in enumerate(df.iterrows()):
    if i == 0: continue # skip first row

Or something like:

for i,(index,row) in enumerate(df.iterrows()):
    if i < 5: continue # skip first 5 rows


The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .