Pandas Datetime: Calculate Number of Weeks Between Dates in Two Columns

前端 未结 2 852
眼角桃花
眼角桃花 2021-01-03 08:37

Let\'s say I have a dataframe with two columns that contain dates, and I want to create a new columns whose value is the number of months between those dates.



        
2条回答
  •  离开以前
    2021-01-03 08:53

    I'm not sure how to do it in python but the steps I would do:

    • Convert dates into number of days since the epoch
    • Subtract date1 from date2
    • Divide by 7

提交回复
热议问题