我有一本嵌套列表的字典
d = {'IBGB100': [RealTimeBar(time=datetime.datetime(2019, 2, 21, 19, 17, tzinfo=datetime.timezone.utc), open_=7169.42, high=7169.67, low=7169.42, close=7169.42, volume=-1, wap=-1.0, count=-1),
RealTimeBar(time=datetime.datetime(2019, 2, 21, 19, 17, 5, tzinfo=datetime.timezone.utc), open_=7169.42, high=7169.42, low=7168.92, close=7168.92, volume=-1, wap=-1.0, count=-1)],
'IBEU50': [RealTimeBar(time=datetime.datetime(2019, 2, 21, 19, 17, tzinfo=datetime.timezone.utc), open_=3262.455, high=3262.455, low=3262.455, close=3262.455, volume=-1, wap=-1.0, count=-1),
RealTimeBar(time=datetime.datetime(2019, 2, 21, 19, 17, 5, tzinfo=datetime.timezone.utc), open_=3262.455, high=3262.455, low=3262.455, close=3262.455, volume=-1, wap=-1.0, count=-1)],
'IBDE30': [RealTimeBar(time=datetime.datetime(2019, 2, 21, 19, 17, tzinfo=datetime.timezone.utc), open_=11417.15, high=11417.655, low=11416.9, close=11416.9, volume=-1, wap=-1.0, count=-1),
RealTimeBar(time=datetime.datetime(2019, 2, 21, 19, 17, 5, tzinfo=datetime.timezone.utc), open_=11416.9, high=11416.905, low=11416.15, close=11416.65, volume=-1, wap=-1.0, count=-1)]}
我正在尝试转换成这种格式的数据帧
instrument datetime open high low close volume wap count
'IBGB100' 2019, 2, 21, 19, 17, 7169.42 7169.67 7169.42 7169.42 -1 -1.0 -1
2019, 2, 21, 19, 17, 5, 7169.42 7169.42 7168.92 7168.92 -1 -1.0 -1
'IBEU50' 2019, 2, 21, 19, 17, 3262.455 3262.455 3262.455 3262.455 -1 -1.0 -1
2019, 2, 21, 19, 17, 5, 3262.455 3262.455 3262.455 3262.455 -1 -1.0 -1
'IBDE30' 2019, 2, 21, 19, 17, 11417.15 11417.655 11416.9 11416.9 -1 -1.0 -1
2019, 2, 21, 19, 17, 5, 11416.9 11416.905 11416.15 11416.65 -1 -1.0 -1
你知道吗pd.数据帧(d) .transpose()使我接近,但我无法计算如何以列的形式访问嵌套列表数据。你知道吗
嵌套列表以1xN形状(即按列展开)返回,而不是我需要的Nx8形状(即按行展开)。你知道吗
0 1
'IBGB100' RealTimeBar(...) RealTimeBar(...)
'IBEU50' RealTimeBar(...) RealTimeBar(...)
'IBDE30' RealTimeBar(...) RealTimeBar(...)
目前没有回答
相关问题 更多 >
编程相关推荐