I would like to consolidate the futures data into a 3 minute trading bar for the futures data in the research environment.

I have come across the tutorial section and the respective consolidators, tradingbar doc section but could not make my code to work. Any help would be appreciated, thanks.

start = datetime(2021, 10, 1)
end = datetime(2022, 1, 1)
qb = QuantBook()
future = qb.AddFuture(Futures.Indices.MicroNASDAQ100EMini,Resolution.Minute)
symbol = future.Symbol

continuous_history = qb.History(symbol, start, end)

# Set up a consolidator and a RollingWindow to save the data
consolidator = TradeBarConsolidator(timedelta(3))
window = RollingWindow[TradeBar](20)

# Attach a consolidation handler method that saves the consolidated bars in the RollingWindow   
consolidator.DataConsolidated += lambda _, bar: window.Add(bar)

# Iterate the historical market data and feed each bar into the consolidator
for bar in continuous_history.itertuples():
    tradebar = TradeBar(bar.Index[2], bar.Index[1], bar.open, bar.high, bar.low, bar.close, bar.volume)
    consolidator.Update(tradebar)

Code work till the line above and code below does not work. I fail to convert the rolling window into pandas dataframe.

#Convert the RollingWindows' data into pandas.DataFrame.
dataframe = pd.DataFrame(window).set_index('time')

Thanks.