dateindex = pd.date_range(pd.datetime.today(), periods=4, freq='W', dtype='datetime64[ns]')
to generate some dates.
Can I get something like this to generate dates in the past. I tried -4 but no joy.
Cheers Kevin
dateindex = pd.date_range(pd.datetime.today(), periods=4, freq='W', dtype='datetime64[ns]')
to generate some dates.
Can I get something like this to generate dates in the past. I tried -4 but no joy.
Cheers Kevin
In date_range 2 of start, end, periods should be specified. It assumes your date to be start, unless you specify otherwise.
pd.date_range(end = pd.datetime.today(), periods=4, freq='W', dtype='datetime64[ns]')
You get
DatetimeIndex(['2017-08-13 13:18:39.525080', '2017-08-20 13:18:39.525080',
'2017-08-27 13:18:39.525080', '2017-09-03 13:18:39.525080'],
dtype='datetime64[ns]', freq='W-SUN')