First page Back Continue Last page Overview Graphics

Changing the Index

We can see that an index (0,1,2, ...) has been automatically assigned to the DataFrame. We can also assign a custom index to the DataFrame object:

ordinals = ["first", "second",

"third", "fourth",

"fifth", "sixth",

"seventh", "eigth",

"ninth", "tenth",

"eleventh", "twelvth",

"thirteenth"]

city_frame = pd.DataFrame(cities, index=ordinals)

print(city_frame)