Pythonic difference between two dates in years?

后端 未结 12 2475
醉酒成梦
醉酒成梦 2020-12-02 16:21

Is there a more efficient way of doing this below? I want to have the difference in years between two dates as a single scalar. Any suggestions are welcome.

         


        
12条回答
  •  独厮守ぢ
    2020-12-02 16:59

    I think what you're looking for is:

    difference_in_years = difference.dt.days / 365.25
    

提交回复
热议问题