Tutorials References Exercises Videos Menu
Website Get Certified Pro NEW

Pandas DataFrame itertuples() Method

❮ DataFrame Reference


Example

Iterate the rows of the DataFrame, and print each row as a tuple:

import pandas as pd

data = {
  "firstname": ["Sally", "Mary", "John"],
  "age": [50, 40, 30]
}

df = pd.DataFrame(data)

for row in df.itertuples():
  print(row)
Try it Yourself »

Definition and Usage

The itertuples() method generates an iterator object of the DataFrame, returning each row as a Pyton Tuple object.


Syntax

dataframe.itertuples()

Parameters

The itertuples() method takes no parameters.


Return Value

an iterator, where each row is returned as a Pyton Tuple object.


❮ DataFrame Reference