pandas.DataFrame.itertuples¶
- DataFrame.itertuples(index=True)¶
Iterate over the rows of DataFrame as tuples, with index value as first element of the tuple.
Parameters: index : boolean, default True
If True, return the index as the first element of the tuple.
See also
Examples
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [0.1, 0.2]}, index=['a', 'b']) >>> df col1 col2 a 1 0.1 b 2 0.2 >>> for row in df.itertuples(): ... print(row) ('a', 1, 0.10000000000000001) ('b', 2, 0.20000000000000001)