I am trying to create a semi-annual date range using Python. Pandas provides a pd.date_range function to help with this, but I would like my date range to start from the end date and repeat back.
For example, given input:
start = datetime.datetime(2016 ,2, 8) end = datetime.datetime(2018 , 6, 1) pd.date_range(start, end, freq='6m')
Result:
DatetimeIndex(['2016-02-29', '2016-08-31', '2017-02-28', '2017-08-31', '2018-02-28'])
How to create the following:
DatetimeIndex(['2016-02-08', '2016-06-01', '2016-12-01', '2017-06-01', '2017-12-01', '2018-06-01'])
source share