0

I have a dataframe with multiple dates, such as '2019-05-01' and I want to substract it to get e.g. 4 (2019-09-01 - 2019-05-01). Those are two columns.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
Adam_Gie
  • 11
  • 3

1 Answers1

0
df['delta'] = [ (x.year -  y.year) * 12 + (x.month -  y.month) for x, y in zip(df['date1'],df['date2'])]
ZygD
  • 22,092
  • 39
  • 79
  • 102
Adam_Gie
  • 11
  • 3