change column values in CSV using python

后端 未结 2 768
孤城傲影
孤城傲影 2020-12-22 09:12

Let say this in the input CSV file.

I would like to go over the Babys column and change it to increasing number by 1.

what i did is to

2条回答
  •  [愿得一人]
    2020-12-22 09:38

    You can use python pandas to increase the column number by n:

    import pandas
    data_df = pandas.read_csv('input.csv')
    data_df = data_df['age'].apply(lambda x: x+n)
    print data_df
    

    for adding 1 replace n by 1.

提交回复
热议问题