Pandas reset index doesn't seem to work?

前端 未结 4 514
星月不相逢
星月不相逢 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条回答
  •  悲&欢浪女
    2020-12-08 11:16

    As an extension of in code veritas's answer... instead of doing del at the end:

    test = test.reset_index()
    del test['index']
    

    You can set drop to True.

    test = test.reset_index(drop=True)
    

提交回复
热议问题