How to Add Incremental Numbers to a New Column Using Pandas

前端 未结 6 1072
感情败类
感情败类 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:30

    You can also simply set your pandas column as list of id values with length same as of dataframe.

    df['New_ID'] = range(880, 880+len(df))
    

    Reference docs : https://pandas.pydata.org/pandas-docs/stable/missing_data.html

提交回复
热议问题