For me work generating with periods
:
print df
date
0 2016-01-01
1 2016-02-01
2 2016-03-01
3 2016-04-02
print pd.date_range(df['date'].iloc[0], periods=12, freq='M')
DatetimeIndex(['2016-01-31', '2016-02-29', '2016-03-31', '2016-04-30',
'2016-05-31', '2016-06-30', '2016-07-31', '2016-08-31',
'2016-09-30', '2016-10-31', '2016-11-30', '2016-12-31'],
dtype='datetime64[ns]', freq='M')
Why last value is missing - check in the end:
months = df['date']
print pd.date_range(months.iloc[0], months.iloc[3], freq='M')
DatetimeIndex(['2016-01-31', '2016-02-29', '2016-03-31'], dtype='datetime64[ns]', freq='M')
The start and end dates are strictly inclusive. So it will not generate any dates outside of those dates if specified.