The default index of a dataframe is the row numbers. These are generated automatically when a dataframe is created and no index is specified. Here is an example.
We create a dataframe from a list of lists:
towns=[['Stockholm', 'Sweden', 188,975904],
['Malmö', 'Sweden', 322, 316588],
['Oslo', 'Norway', 481, 693491],
['Bergen', 'Norway', 464, 28392]]
town=pd.DataFrame(towns, columns=['City','Country','area','population'])
This produces a dataframe with rows labeled by their row numbers:
City Country area population
0 Stockholm Sweden 188 975904
1 Malmö Sweden 322 316588
2 Oslo Norway 481 693491
3 Bergen Norway 464 28392
We can change this by choosing a column to be the index. The column can be duplicated—one serving as the index and the other belonging to the...