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

前端 未结 3 840
一整个雨季
一整个雨季 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:23

    For this, you can do the following(I created an example dataframe):

    price_of_items = pd.DataFrame({
    "Wired Keyboard":["$7","4.3","12000"],"Wireless Keyboard":["$13","4.6","14000"]
                                 })
    price_of_items.index += 1
    

提交回复
热议问题