freq = '1m'
for date, df in df_trade.resample(freq):
print(date)
start = date - datetime.timedelta(freq)
we know that here date
is the end time of resample under the given freq
e.g. for the interval ('2021-03-01', '2021-03-31')
, date
is '2021-03-31'
.
How could I simply get the start? start = date - datetime.timedelta(freq)
is a way. However it should convert '1m'
to 'days'
which is not a direct way (say if i change the freq
, we may not get the exact start date of resample)