0

I need to create a new column that calculates the age of each row in months (calculated by subtracting join_month from post_month). I was able to calculate the age in days using the below, but have struggled with calculating the age in months.

df['age'] = (df['post_month'] - (df['join_month'])).dt.days

Current dataframe looks like this:

join_month post_month binary_target
2018-01-01 2018-04-01 1
2018-01-01 2018-04-01 1
2018-01-01 2018-04-01 0
2018-01-01 2018-04-01 0
Connor95
  • 97
  • 4

0 Answers0