Loop over Dataframe - Pandas

PHOTO EMBED

Thu Nov 25 2021 16:42:08 GMT+0000 (Coordinated Universal Time)

Saved by @Sourabh #list #forloop #for #loop ##dictionary

#Iterating over a Pandas DataFrame is typically done with the iterrows()
# Import cars data
import pandas as pd
cars = pd.read_csv('cars.csv', index_col = 0)

# Iterate over rows of cars
for lab,row in cars.iterrows():
    print(lab)
    print(row)
content_copyCOPY

Iterating over a Pandas DataFrame is typically done with the iterrows()