Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({'num_legs': [4, 2], 'num_wings': [0, 2]},
                  index=['fox', 'eagle'])
df
Out[2]:
num_legs num_wings
fox 4 0
eagle 2 2

Pandas: DataFrame - intertuples.

In [3]:
for row in df.itertuples():
    print(row)
Pandas(Index='fox', num_legs=4, num_wings=0)
Pandas(Index='eagle', num_legs=2, num_wings=2)

Pandas: DataFrame - intertuples print row.

In [4]:
for row in df.itertuples(index=False):
    print(row)
Pandas(num_legs=4, num_wings=0)
Pandas(num_legs=2, num_wings=2)

Pandas: DataFrame - intertuples, index false, print row.

With the name parameter set we set a custom name for the yielded named tuples:

In [5]:
for row in df.itertuples(name='Animal'):
    print(row)
Animal(Index='fox', num_legs=4, num_wings=0)
Animal(Index='eagle', num_legs=2, num_wings=2)

Pandas: DataFrame - intertuples, With the parameter set we set a custom  name for the yielded named tuples.