First page Back Continue Last page Overview Graphics

Alternative Approach

Alternatively, we can us the method set_index to turn a column into an index. "set_index" does not work in-place, it returns a new data frame with the chosen column as the index:

city_frame = pd.DataFrame(cities)

city_frame2 = city_frame.set_index("country")

city_frame2