From pd.date_range(\'2016-01\', \'2016-05\', freq=\'M\', ).strftime(\'%Y-%m\'), the last month is 2016-04, but I was expecting it to be 2016
pd.date_range(\'2016-01\', \'2016-05\', freq=\'M\', ).strftime(\'%Y-%m\')
2016-04
2016
Include the day when specifying the dates in date_range call
date_range
pd.date_range('2016-01-31', '2016-05-31', freq='M', ).strftime('%Y-%m') array(['2016-01', '2016-02', '2016-03', '2016-04', '2016-05'], dtype='|S7')