How to Add Incremental Numbers to a New Column Using Pandas

前端 未结 6 1074
感情败类
感情败类 2020-12-24 04:55

I have this simplified dataframe:

ID   Fruit
F1   Apple
F2   Orange
F3   Banana 

I want to add in the begining of the dataframe a new colum

6条回答
  •  误落风尘
    2020-12-24 05:22

    import numpy as np
    
    df['New_ID']=np.arange(880,880+len(df.Fruit))
    df=df.reindex(columns=['New_ID','ID','Fruit'])
    

提交回复
热议问题