In Python pandas, start row index from 1 instead of zero without creating additional column

前端 未结 3 855
一整个雨季
一整个雨季 2020-12-13 23:57

I know that I can reset the indices like so

df.reset_index(inplace=True)

but this will start the index from 0. I want to start

3条回答
  •  自闭症患者
    2020-12-14 00:19

    You can also specify the start value using index range like below. RangeIndex is supported in pandas.

    #df.index
    

    default value is printed, (start=0,stop=lastelement, step=1)

    You can specify any start value range like this:

    df.index = pd.RangeIndex(start=1, stop=600, step=1)
    

    Refer: pandas.RangeIndex

提交回复
热议问题