I have a data frame which consists of data aggregated over certain time span with 'date'as one of the columns. Now every day a new data with exactly same columns is added to this aggregated data. Now I want to apply a filter on this aggregated data, that post appending new daily data I want only recent nine months data.

Suppose df\_old is your aggregated data and new data is df\_new. Currently I am doing like this

```
#Append new data to old aggregated data with same columns
df_old=df_old.append(df_new)
df_old['date']=pd.to_datetime(df_old['date'])
max_date=max(df_old['date']
df_old['date_diff']=(max_date - df_old['date'])
##Considering a calender month has 30 days and three months have 31 days
df_old.loc[df_old.date_diff <=273]

```

Now I know the above method involves hard coding and is not efficient. I would appreciate if someone can help with some automated way of doing this.