pandas的for循环,iterrows方法,遍历标题和行内容
# Import cars data
import pandas as pd
cars = pd.read_csv('cars.csv', index_col = 0)
# Code for loop that adds COUNTRY column
for lab, row in cars.iterrows():
cars.loc[lab,'COUNTRY'] = str.upper(row['country'])
# Print cars
print(cars)