["python","pandas","date"]
Add months to a date in Pandas

I'm trying to figure out how to add 3 months to a date in a Pandas dataframe, while keeping it in the date format, so I can use it to lookup a range. This is what I've tried: #create dataframe df = pd.DataFrame([pd.Timestamp('20161011'), pd.Timestamp('20161101') ], columns=['date']) #create a future month period plus_month_period = 3 #calculate date + future period df['future_date'] = plus_month_period.astype("timedelta64[M]") However, I get the following error: AttributeError: 'int' object has no attribute 'astype'
You could use pd.DateOffset In [1756]: df.date + pd.DateOffset(months=plus_month_period) Out[1756]: 0 2017-01-11 1 2017-02-01 Name: date, dtype: datetime64[ns] Details In [1757]: df Out[1757]: date 0 2016-10-11 1 2016-11-01 In [1758]: plus_month_period Out[1758]: 3