Pandas ohlc 重采样:在重采样刻度数据时获取 00:00:00 时间和不正确的日期

Pandas ohlc resampling: Getting 00:00:00 time and incorrect date when resampling tick data

这就是我用来将数据添加到我的刻度数据框的方法:

dfTick = {
    'time': data['time'],
    'mid': data['mid'],
}

tick = pd.DataFrame(dfTick).set_index('time')
tick.index = pd.DatetimeIndex(tick.index)

current_candle = current_candle.append(tick)

这是数据框中的报价数据:

                                         mid
time
2021-04-08 01:37:05.803333138+00:00  0.76097
2021-04-08 01:37:20.152602558+00:00  0.76094
2021-04-08 01:37:53.382876759+00:00  0.76097
2021-04-08 01:37:56.856087693+00:00  0.76094
2021-04-08 01:37:57.148063649+00:00  0.76090
2021-04-08 01:38:16.598799961+00:00  0.76087
2021-04-08 01:38:30.978559522+00:00  0.76092
2021-04-08 01:38:33.302859897+00:00  0.76096
2021-04-08 01:38:43.222445326+00:00  0.76099
2021-04-08 01:39:08.770058921+00:00  0.76104
2021-04-08 01:39:32.495760219+00:00  0.76100
2021-04-08 01:39:32.694723608+00:00  0.76096
2021-04-08 01:39:34.243899267+00:00  0.76099

我正在用它制作蜡烛(我正在制作 5 分钟蜡烛并将其附加到另一帧):

current_candle['mid'].resample(5M).ohlc()

这就是我要说的:

                           open     high      low    close
time
2021-04-30 00:00:00+00:00  0.76097  0.76104  0.76087  0.76099

current_candle['mid'].resample('5M').ohlc()中,M表示月份。你可能想要 5min.