最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - dataframe resample get the start time - Stack Overflow

programmeradmin0浏览0评论
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)

发布评论

评论列表(0)

  1. 暂无评论