Subtract a year from a datetime column in pandas
Use DateOffset:
df["NEW_DATE"] = df["ACC_DATE"] - pd.offsets.DateOffset(years=1)
print (df)
ACC_DATE NEW_DATE
index
538 2006-04-07 2005-04-07
550 2006-04-12 2005-04-12
You can use DateOffset
to achieve this:
In[88]:
df['NEW_DATE'] = df['ACC_DATE'] - pd.DateOffset(years=1)
df
Out[88]:
ACC_DATE NEW_DATE
index
538 2006-04-07 2005-04-07
550 2006-04-12 2005-04-12