Remove Row Index dataframe pandas

后端 未结 3 1010
耶瑟儿~
耶瑟儿~ 2020-12-17 00:52

Given a df

in[0]df1
out[0]
        DATE    REVENUE    COST    POSITION
FACTOR
0    2017/01/01    1000    900    10
1    2017/01/01    900     700    9
2    2         


        
3条回答
  •  星月不相逢
    2020-12-17 01:01

    Try using:

    df1.reset_index(drop=True)
    

    This resets the index to the default integer index and removes the original one. If you want to assign this change to original dataframe it is easier to use:

    df1.reset_index(drop=True, inplace=True)
    

    As it will edit the df1 dataframe without making a copy of it.

提交回复
热议问题