0

My df has the columns 'Country' and 'Country Code' as the current index. How can I remove this index and create a new one that just counts the rows? I´ll leave the picture of how it´s looking. All I want to do is add a new index next to Country. Thanks a lot!

enter image description here

fiona
  • 89
  • 7
  • 1
    See [this answer](https://stackoverflow.com/a/46920777/15497888) specifically. But you're looking for [DataFrame.reset_index](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.reset_index.html). Either `df = df.reset_index()` or `df.reset_index(inplace=True)` – Henry Ecker Aug 31 '21 at 14:36

1 Answers1

1

If you are using a pandas DataFrame and your DataFrame is called df:

df = df.reset_index(drop=False)
Odhian
  • 351
  • 5
  • 14