Iterate over a dataframe by rows

In [1]:
import pandas as pd
df = pd.DataFrame([['AA', 1],['BB', 2],['CC', 3]], columns = ['name','value'])

In [2]:
df


Out[2]:
name value
0 AA 1
1 BB 2
2 CC 3

In [3]:
for i, row in df.iterrows():
    print(row['name'], row['value'])


AA 1
BB 2
CC 3

In [14]:
for row in df.itertuples():
    print(row)


Pandas(Index=0, name='AA', value=1)
Pandas(Index=1, name='BB', value=2)
Pandas(Index=2, name='CC', value=3)

In [ ]: