You can use .union to add the following boolean after initializing date_range . It should work as written for any frequency:
d = pd.date_range('2016-01', '2016-05', freq='M') d = d.union([d[-1] + 1]).strftime('%Y-%m')
Alternatively, you can use period_range instead of date_range . Depending on what you intend to do, this may not be right, but it satisfies your question:
pd.period_range('2016-01', '2016-05', freq='M').strftime('%Y-%m')
In any case, the resulting output will be as expected:
['2016-01' '2016-02' '2016-03' '2016-04' '2016-05']
source share