0

I have a large dataset which I filtered by location. The end result is something like this:

   column 1  column 2
 0        a         1
 106      b         2
 178      c         3

I guessed that the index values are skipping all over the place since the all the columns with the same locations aren't consecutive. To reset the indices, I did df.reindex(index = np.arange(len(df))), and it worked... but broke everything else. The output is this:

   column 1  column 2
 0        a         1
 1      NAN       NAN
 12     NAN       NAN

I don't have any idea why this is happening, and how I can fix this. Thanks for any help provided!

1 Answers1

0

Use reset_index:

>>> df.reset_index(drop=True)
  column 1  column 2
0        a         1
1        b         2
2        c         3
Corralien
  • 109,409
  • 8
  • 28
  • 52