Pandas reset index doesn't seem to work?

前端 未结 4 499
星月不相逢
星月不相逢 2020-12-08 10:52

I\'m not sure where I am astray but I cannot seem to reset the index on a dataframe.

When I run test.head(), I get the output below:

4条回答
  •  -上瘾入骨i
    2020-12-08 10:59

    reset_index by default does not modify the DataFrame; it returns a new DataFrame with the reset index. If you want to modify the original, use the inplace argument: df.reset_index(drop=True, inplace=True). Alternatively, assign the result of reset_index by doing df = df.reset_index(drop=True).

提交回复
热议问题