iterate over pandas dataframe using itertuples

When using itertuples you get a named tuple for every row. By default, you can access the index value for that row with row.Index.

If the index value isn’t what you were looking for then you can use enumerate

for i, row in enumerate(df.itertuples(), 1):
    print(i, row.name)

enumerate takes the place of an ugly counter construct

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)