Pandas Note
- By Abhishek Bajpai
- Sun 26 August 2018
Iterate over rows in a DataFrame
iterrows is a generator which yield both index and row
import pandas as pd
df = pd.DataFrame([
{'Name': 'Abhishek', 'Age': 31},
{'Name': 'Anurag', 'Age': 20},])
for index, row in df.iterrows():
print(row['Name'], row['Age'])