calculate datetime-difference in years, months, etc. in a new pandas dataframe column

后端 未结 7 2278
长发绾君心
长发绾君心 2021-02-07 05:34

I have a pandas dataframe looking like this:

Name    start        end
A       2000-01-10   1970-04-29

I want to add a new column providing the

7条回答
  •  醉酒成梦
    2021-02-07 06:26

    You can try by creating a new column with years in this way:

    df['diff_year'] = df['diff'] / np.timedelta64(1, 'Y')
    

提交回复
热议问题