I tried this code:
df['ExperienceDate'] = (df['IssueDate']) - relativedelta(years=5)
It shows an error: TypeError: unsupported operand type(s) for -: 'DatetimeIndex' and 'relativedelta'
I tried this code:
df['ExperienceDate'] = (df['IssueDate']) - relativedelta(years=5)
It shows an error: TypeError: unsupported operand type(s) for -: 'DatetimeIndex' and 'relativedelta'
you can check a similar question. You can't compare relativedelta object with timedelta. And there is no timedelta as big as year
A solution keeping the same module datetime :
diff=timedelta(days=(5*365)) # convert the number of year into a number of day
df['ExperienceDate']= df['IssueDate']-diff # then substract
Result :
IssueDate ExperienceDate
0 1995-02-01 1990-02-02
This worked
df['ExperienceDate'] = df['IssueDate'].apply(lambda x:x - relativedelta(years=5))