DataFrame调用其他列内容,新建一列的两种方法,apply更高效
# Import cars data
import pandas as pd
cars = pd.read_csv('cars.csv', index_col = 0)
# Use .apply(str.upper)
#for lab, row in cars.iterrows() :
#cars.loc[lab, "COUNTRY"] = row["country"].upper()
cars['COUNTRY'] = cars['country'].apply(str.upper)
print(cars)