0

I've just created a new dataframe, that is a subset of a larger one. (image link below) However, it is making the first column and index, which I do not want. I've tried looking for answers, but everything seems to relate to resetting and index

I either want to add a column that will serve as a new index (just numbered would be fine), or just change this column so its no longer an index

Data Frame Subset

Layne Bernardo
  • 676
  • 3
  • 12
lwoodcock
  • 13
  • 4
  • Please upload your image into the Stack Overflow text editor, into the question directly. –  Jun 04 '22 at 01:16
  • Welcome to Stack Overflow. How exactly did you create the DataFrame? Did you try reading that documentation, to look for a way to add the index directly during creation? – Karl Knechtel Jun 04 '22 at 01:24

1 Answers1

1

You can try this:

# keep the index as a column
df = df.reset_index()

# drop it
df = df.reset_index(drop=True)
John Stud
  • 1,506
  • 23
  • 46