# Import cars data import pandas as pd cars = pd.read_csv('cars.csv', index_col = 0) # Adapt for loop for lab, row in cars.iterrows() : print(lab + ": " + str(row['cars_per_cap'])) #Something new # 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'] = row['country'].upper() # Print cars print(cars)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter