【发布时间】:2018-02-28 19:33:33
【问题描述】:
我有一个带有 MultiIndex 的 Pandas DataFrame,如下所示:
我正在尝试使用 IndexSlice 检索几行:
idx=pd.IndexSlice
prices.loc[idx[["2016-09-19 13:30:00":"2016-09-19 14:30:00"],"Chinese Renminbioffshore"],:]
但我收到错误:
SyntaxError: invalid syntax
按照the documentation (scroll to in:72)的说法,我应该可以做到的。
有人有什么建议吗?
这里是重新创建数据框的数据:
编辑:似乎我无法发布数据来重新创建这个数据框,因为它使问题的比例看起来像代码对 SO 来说太大了......希望这个问题仍然可以解决。
EDIT2:也许这样发布会有所帮助?
{'ID': {(Timestamp('2016-09-19 13:30:00'), '10 Year US Treasury Note'): 6211,
(Timestamp('2016-09-19 13:30:00'), '30 Day Fed Funds'): 37585,
(Timestamp('2016-09-19 13:30:00'), 'Bloomberg Commodity Index'): 3757,
(Timestamp('2016-09-19 13:30:00'), 'E-mini S&P 500'): 1,
(Timestamp('2016-09-19 13:30:00'), 'Gold'): 33824,
(Timestamp('2016-09-19 13:30:00'), 'Henry Hub Natural Gas'): 41328,
(Timestamp('2016-09-19 13:30:00'), 'Lean Hogs'): 9971,
(Timestamp('2016-09-19 13:30:00'), 'Light Sweet Crude Oil'): 45089,
(Timestamp('2016-09-19 13:30:00'), 'Live Cattle'): 21274,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Copper Index'): 30063,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Palladium Index'): 17513,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Platinum Index'): 26302,
(Timestamp('2016-09-19 13:30:00'), 'Soybean Meal Futures'): 23788,
(Timestamp('2016-09-19 13:30:00'), 'Soybean Oil Futures'): 14999,
(Timestamp('2016-09-19 13:30:00'), 'Wheat Futures'): 12485,
(Timestamp('2016-09-19 14:00:00'), '10 Year US Treasury Note'): 6212,
(Timestamp('2016-09-19 14:00:00'), '30 Day Fed Funds'): 37586,
(Timestamp('2016-09-19 14:00:00'), 'Bloomberg Commodity Index'): 3758,
(Timestamp('2016-09-19 14:00:00'), 'E-mini S&P 500'): 2,
(Timestamp('2016-09-19 14:00:00'), 'Gold'): 33825,
(Timestamp('2016-09-19 14:00:00'), 'Henry Hub Natural Gas'): 41329,
(Timestamp('2016-09-19 14:00:00'), 'Lean Hogs'): 9972,
(Timestamp('2016-09-19 14:00:00'), 'Light Sweet Crude Oil'): 45090,
(Timestamp('2016-09-19 14:00:00'), 'Live Cattle'): 21275,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Copper Index'): 30064,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Palladium Index'): 17514,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Platinum Index'): 26303,
(Timestamp('2016-09-19 14:00:00'), 'Soybean Meal Futures'): 23789,
(Timestamp('2016-09-19 14:00:00'), 'Soybean Oil Futures'): 15000,
(Timestamp('2016-09-19 14:00:00'), 'Wheat Futures'): 12486,
(Timestamp('2016-09-19 14:30:00'), '10 Year US Treasury Note'): 6213,
(Timestamp('2016-09-19 14:30:00'), '30 Day Fed Funds'): 37587,
(Timestamp('2016-09-19 14:30:00'), 'Bloomberg Commodity Index'): 3759,
(Timestamp('2016-09-19 14:30:00'), 'E-mini S&P 500'): 3,
(Timestamp('2016-09-19 14:30:00'), 'Gold'): 33826,
(Timestamp('2016-09-19 14:30:00'), 'Henry Hub Natural Gas'): 41330,
(Timestamp('2016-09-19 14:30:00'), 'Lean Hogs'): 9973,
(Timestamp('2016-09-19 14:30:00'), 'Light Sweet Crude Oil'): 45091,
(Timestamp('2016-09-19 14:30:00'), 'Live Cattle'): 21276,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Copper Index'): 30065,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Palladium Index'): 17515,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Platinum Index'): 26304,
(Timestamp('2016-09-19 14:30:00'), 'Soybean Meal Futures'): 23790,
(Timestamp('2016-09-19 14:30:00'), 'Soybean Oil Futures'): 15001,
(Timestamp('2016-09-19 14:30:00'), 'Wheat Futures'): 12487,
(Timestamp('2016-09-19 15:00:00'), '10 Year US Treasury Note'): 6214,
(Timestamp('2016-09-19 15:00:00'), '30 Day Fed Funds'): 37588,
(Timestamp('2016-09-19 15:00:00'), 'Bloomberg Commodity Index'): 3760,
(Timestamp('2016-09-19 15:00:00'), 'E-mini S&P 500'): 4,
(Timestamp('2016-09-19 15:00:00'), 'Gold'): 33827},
'close': {(Timestamp('2016-09-19 13:30:00'),
'10 Year US Treasury Note'): 128.671875,
(Timestamp('2016-09-19 13:30:00'), '30 Day Fed Funds'): 98.879999999999995,
(Timestamp('2016-09-19 13:30:00'),
'Bloomberg Commodity Index'): 84.900000000000006,
(Timestamp('2016-09-19 13:30:00'), 'E-mini S&P 500'): 2132.0,
(Timestamp('2016-09-19 13:30:00'), 'Gold'): 1339.4000000000001,
(Timestamp('2016-09-19 13:30:00'),
'Henry Hub Natural Gas'): 4.8360000000000003,
(Timestamp('2016-09-19 13:30:00'), 'Lean Hogs'): 55.774999999999999,
(Timestamp('2016-09-19 13:30:00'),
'Light Sweet Crude Oil'): 49.420000000000002,
(Timestamp('2016-09-19 13:30:00'), 'Live Cattle'): 97.224999999999994,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Copper Index'): 2.2149999999999999,
(Timestamp('2016-09-19 13:30:00'),
'NYMEX Palladium Index'): 684.29999999999995,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Platinum Index'): 1036.0,
(Timestamp('2016-09-19 13:30:00'),
'Soybean Meal Futures'): 336.30000000000001,
(Timestamp('2016-09-19 13:30:00'),
'Soybean Oil Futures'): 34.460000000000001,
(Timestamp('2016-09-19 13:30:00'), 'Wheat Futures'): 497.0,
(Timestamp('2016-09-19 14:00:00'), '10 Year US Treasury Note'): 128.609375,
(Timestamp('2016-09-19 14:00:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 14:00:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 14:00:00'), 'E-mini S&P 500'): 2131.0,
(Timestamp('2016-09-19 14:00:00'), 'Gold'): 1339.0999999999999,
(Timestamp('2016-09-19 14:00:00'),
'Henry Hub Natural Gas'): 4.8179999999999996,
(Timestamp('2016-09-19 14:00:00'), 'Lean Hogs'): 55.174999999999997,
(Timestamp('2016-09-19 14:00:00'),
'Light Sweet Crude Oil'): 49.719999999999999,
(Timestamp('2016-09-19 14:00:00'), 'Live Cattle'): 97.275000000000006,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Copper Index'): 2.2145000000000001,
(Timestamp('2016-09-19 14:00:00'),
'NYMEX Palladium Index'): 692.39999999999998,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Platinum Index'): 1039.0,
(Timestamp('2016-09-19 14:00:00'), 'Soybean Meal Futures'): 335.0,
(Timestamp('2016-09-19 14:00:00'), 'Soybean Oil Futures'): 34.5,
(Timestamp('2016-09-19 14:00:00'), 'Wheat Futures'): 494.25,
(Timestamp('2016-09-19 14:30:00'), '10 Year US Treasury Note'): 128.609375,
(Timestamp('2016-09-19 14:30:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 14:30:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 14:30:00'), 'E-mini S&P 500'): 2128.0,
(Timestamp('2016-09-19 14:30:00'), 'Gold'): 1338.2,
(Timestamp('2016-09-19 14:30:00'),
'Henry Hub Natural Gas'): 4.8179999999999996,
(Timestamp('2016-09-19 14:30:00'), 'Lean Hogs'): 55.024999999999999,
(Timestamp('2016-09-19 14:30:00'),
'Light Sweet Crude Oil'): 49.689999999999998,
(Timestamp('2016-09-19 14:30:00'), 'Live Cattle'): 97.125,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Copper Index'): 2.2145000000000001,
(Timestamp('2016-09-19 14:30:00'),
'NYMEX Palladium Index'): 688.79999999999995,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Platinum Index'): 1040.0,
(Timestamp('2016-09-19 14:30:00'),
'Soybean Meal Futures'): 333.19999999999999,
(Timestamp('2016-09-19 14:30:00'),
'Soybean Oil Futures'): 34.530000000000001,
(Timestamp('2016-09-19 14:30:00'), 'Wheat Futures'): 491.25,
(Timestamp('2016-09-19 15:00:00'), '10 Year US Treasury Note'): 128.640625,
(Timestamp('2016-09-19 15:00:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 15:00:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 15:00:00'), 'E-mini S&P 500'): 2129.0,
(Timestamp('2016-09-19 15:00:00'), 'Gold'): 1338.2},
'high': {(Timestamp('2016-09-19 13:30:00'),
'10 Year US Treasury Note'): 128.703125,
(Timestamp('2016-09-19 13:30:00'), '30 Day Fed Funds'): 98.879999999999995,
(Timestamp('2016-09-19 13:30:00'),
'Bloomberg Commodity Index'): 84.900000000000006,
(Timestamp('2016-09-19 13:30:00'), 'E-mini S&P 500'): 2133.0,
(Timestamp('2016-09-19 13:30:00'), 'Gold'): 1341.2,
(Timestamp('2016-09-19 13:30:00'),
'Henry Hub Natural Gas'): 4.8529999999999998,
(Timestamp('2016-09-19 13:30:00'), 'Lean Hogs'): 56.149999999999999,
(Timestamp('2016-09-19 13:30:00'), 'Light Sweet Crude Oil'): 49.5,
(Timestamp('2016-09-19 13:30:00'), 'Live Cattle'): 97.724999999999994,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Copper Index'): 2.2200000000000002,
(Timestamp('2016-09-19 13:30:00'),
'NYMEX Palladium Index'): 684.79999999999995,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Platinum Index'): 1039.0,
(Timestamp('2016-09-19 13:30:00'),
'Soybean Meal Futures'): 339.30000000000001,
(Timestamp('2016-09-19 13:30:00'),
'Soybean Oil Futures'): 34.469999999999999,
(Timestamp('2016-09-19 13:30:00'), 'Wheat Futures'): 498.25,
(Timestamp('2016-09-19 14:00:00'), '10 Year US Treasury Note'): 128.71875,
(Timestamp('2016-09-19 14:00:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 14:00:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 14:00:00'), 'E-mini S&P 500'): 2134.0,
(Timestamp('2016-09-19 14:00:00'), 'Gold'): 1340.2,
(Timestamp('2016-09-19 14:00:00'),
'Henry Hub Natural Gas'): 4.8410000000000002,
(Timestamp('2016-09-19 14:00:00'), 'Lean Hogs'): 55.774999999999999,
(Timestamp('2016-09-19 14:00:00'),
'Light Sweet Crude Oil'): 49.920000000000002,
(Timestamp('2016-09-19 14:00:00'), 'Live Cattle'): 97.400000000000006,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Copper Index'): 2.2164999999999999,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Palladium Index'): 693.75,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Platinum Index'): 1041.0,
(Timestamp('2016-09-19 14:00:00'), 'Soybean Meal Futures'): 336.5,
(Timestamp('2016-09-19 14:00:00'),
'Soybean Oil Futures'): 34.609999999999999,
(Timestamp('2016-09-19 14:00:00'), 'Wheat Futures'): 497.25,
(Timestamp('2016-09-19 14:30:00'), '10 Year US Treasury Note'): 128.640625,
(Timestamp('2016-09-19 14:30:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 14:30:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 14:30:00'), 'E-mini S&P 500'): 2131.0,
(Timestamp('2016-09-19 14:30:00'), 'Gold'): 1339.7,
(Timestamp('2016-09-19 14:30:00'),
'Henry Hub Natural Gas'): 4.8220000000000001,
(Timestamp('2016-09-19 14:30:00'), 'Lean Hogs'): 55.375,
(Timestamp('2016-09-19 14:30:00'),
'Light Sweet Crude Oil'): 49.880000000000003,
(Timestamp('2016-09-19 14:30:00'), 'Live Cattle'): 97.200000000000003,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Copper Index'): 2.2155,
(Timestamp('2016-09-19 14:30:00'),
'NYMEX Palladium Index'): 692.79999999999995,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Platinum Index'): 1041.0,
(Timestamp('2016-09-19 14:30:00'), 'Soybean Meal Futures'): 335.0,
(Timestamp('2016-09-19 14:30:00'), 'Soybean Oil Futures'): 34.57,
(Timestamp('2016-09-19 14:30:00'), 'Wheat Futures'): 494.5,
(Timestamp('2016-09-19 15:00:00'), '10 Year US Treasury Note'): 128.65625,
(Timestamp('2016-09-19 15:00:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 15:00:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 15:00:00'), 'E-mini S&P 500'): 2130.0,
(Timestamp('2016-09-19 15:00:00'), 'Gold'): 1338.8},
'low': {(Timestamp('2016-09-19 13:30:00'),
'10 Year US Treasury Note'): 128.625,
(Timestamp('2016-09-19 13:30:00'), '30 Day Fed Funds'): 98.879999999999995,
(Timestamp('2016-09-19 13:30:00'),
'Bloomberg Commodity Index'): 84.900000000000006,
(Timestamp('2016-09-19 13:30:00'), 'E-mini S&P 500'): 2125.0,
(Timestamp('2016-09-19 13:30:00'), 'Gold'): 1338.7,
(Timestamp('2016-09-19 13:30:00'),
'Henry Hub Natural Gas'): 4.8029999999999999,
(Timestamp('2016-09-19 13:30:00'), 'Lean Hogs'): 55.100000000000001,
(Timestamp('2016-09-19 13:30:00'),
'Light Sweet Crude Oil'): 49.039999999999999,
(Timestamp('2016-09-19 13:30:00'), 'Live Cattle'): 96.900000000000006,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Copper Index'): 2.2134999999999998,
(Timestamp('2016-09-19 13:30:00'),
'NYMEX Palladium Index'): 681.79999999999995,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Platinum Index'): 1034.0,
(Timestamp('2016-09-19 13:30:00'),
'Soybean Meal Futures'): 336.10000000000002,
(Timestamp('2016-09-19 13:30:00'),
'Soybean Oil Futures'): 34.270000000000003,
(Timestamp('2016-09-19 13:30:00'), 'Wheat Futures'): 493.25,
(Timestamp('2016-09-19 14:00:00'), '10 Year US Treasury Note'): 128.59375,
(Timestamp('2016-09-19 14:00:00'), '30 Day Fed Funds'): 98.879999999999995,
(Timestamp('2016-09-19 14:00:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 14:00:00'), 'E-mini S&P 500'): 2130.0,
(Timestamp('2016-09-19 14:00:00'), 'Gold'): 1338.5999999999999,
(Timestamp('2016-09-19 14:00:00'),
'Henry Hub Natural Gas'): 4.8129999999999997,
(Timestamp('2016-09-19 14:00:00'), 'Lean Hogs'): 55.125,
(Timestamp('2016-09-19 14:00:00'),
'Light Sweet Crude Oil'): 49.240000000000002,
(Timestamp('2016-09-19 14:00:00'), 'Live Cattle'): 96.849999999999994,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Copper Index'): 2.2094999999999998,
(Timestamp('2016-09-19 14:00:00'),
'NYMEX Palladium Index'): 683.85000000000002,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Platinum Index'): 1036.0,
(Timestamp('2016-09-19 14:00:00'),
'Soybean Meal Futures'): 334.69999999999999,
(Timestamp('2016-09-19 14:00:00'),
'Soybean Oil Futures'): 34.450000000000003,
(Timestamp('2016-09-19 14:00:00'), 'Wheat Futures'): 494.25,
(Timestamp('2016-09-19 14:30:00'), '10 Year US Treasury Note'): 128.546875,
(Timestamp('2016-09-19 14:30:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 14:30:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 14:30:00'), 'E-mini S&P 500'): 2127.0,
(Timestamp('2016-09-19 14:30:00'), 'Gold'): 1337.5999999999999,
(Timestamp('2016-09-19 14:30:00'),
'Henry Hub Natural Gas'): 4.8019999999999996,
(Timestamp('2016-09-19 14:30:00'), 'Lean Hogs'): 54.875,
(Timestamp('2016-09-19 14:30:00'),
'Light Sweet Crude Oil'): 49.560000000000002,
(Timestamp('2016-09-19 14:30:00'), 'Live Cattle'): 96.799999999999997,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Copper Index'): 2.2134999999999998,
(Timestamp('2016-09-19 14:30:00'),
'NYMEX Palladium Index'): 688.60000000000002,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Platinum Index'): 1039.0,
(Timestamp('2016-09-19 14:30:00'), 'Soybean Meal Futures'): 333.0,
(Timestamp('2016-09-19 14:30:00'),
'Soybean Oil Futures'): 34.479999999999997,
(Timestamp('2016-09-19 14:30:00'), 'Wheat Futures'): 490.25,
(Timestamp('2016-09-19 15:00:00'), '10 Year US Treasury Note'): 128.59375,
(Timestamp('2016-09-19 15:00:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 15:00:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 15:00:00'), 'E-mini S&P 500'): 2127.0,
(Timestamp('2016-09-19 15:00:00'), 'Gold'): 1337.7},
'open': {(Timestamp('2016-09-19 13:30:00'),
'10 Year US Treasury Note'): 128.6875,
(Timestamp('2016-09-19 13:30:00'), '30 Day Fed Funds'): 98.879999999999995,
(Timestamp('2016-09-19 13:30:00'),
'Bloomberg Commodity Index'): 84.900000000000006,
(Timestamp('2016-09-19 13:30:00'), 'E-mini S&P 500'): 2126.0,
(Timestamp('2016-09-19 13:30:00'), 'Gold'): 1341.2,
(Timestamp('2016-09-19 13:30:00'),
'Henry Hub Natural Gas'): 4.8129999999999997,
(Timestamp('2016-09-19 13:30:00'), 'Lean Hogs'): 55.649999999999999,
(Timestamp('2016-09-19 13:30:00'),
'Light Sweet Crude Oil'): 49.100000000000001,
(Timestamp('2016-09-19 13:30:00'), 'Live Cattle'): 97.599999999999994,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Copper Index'): 2.2170000000000001,
(Timestamp('2016-09-19 13:30:00'),
'NYMEX Palladium Index'): 681.79999999999995,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Platinum Index'): 1039.0,
(Timestamp('2016-09-19 13:30:00'),
'Soybean Meal Futures'): 337.69999999999999,
(Timestamp('2016-09-19 13:30:00'),
'Soybean Oil Futures'): 34.299999999999997,
(Timestamp('2016-09-19 13:30:00'), 'Wheat Futures'): 495.75,
(Timestamp('2016-09-19 14:00:00'), '10 Year US Treasury Note'): 128.671875,
(Timestamp('2016-09-19 14:00:00'), '30 Day Fed Funds'): 98.879999999999995,
(Timestamp('2016-09-19 14:00:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 14:00:00'), 'E-mini S&P 500'): 2132.0,
(Timestamp('2016-09-19 14:00:00'), 'Gold'): 1339.3,
(Timestamp('2016-09-19 14:00:00'),
'Henry Hub Natural Gas'): 4.8380000000000001,
(Timestamp('2016-09-19 14:00:00'), 'Lean Hogs'): 55.774999999999999,
(Timestamp('2016-09-19 14:00:00'),
'Light Sweet Crude Oil'): 49.409999999999997,
(Timestamp('2016-09-19 14:00:00'), 'Live Cattle'): 97.200000000000003,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Copper Index'): 2.2149999999999999,
(Timestamp('2016-09-19 14:00:00'),
'NYMEX Palladium Index'): 684.35000000000002,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Platinum Index'): 1037.0,
(Timestamp('2016-09-19 14:00:00'),
'Soybean Meal Futures'): 336.30000000000001,
(Timestamp('2016-09-19 14:00:00'),
'Soybean Oil Futures'): 34.469999999999999,
(Timestamp('2016-09-19 14:00:00'), 'Wheat Futures'): 497.0,
(Timestamp('2016-09-19 14:30:00'), '10 Year US Treasury Note'): 128.609375,
(Timestamp('2016-09-19 14:30:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 14:30:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 14:30:00'), 'E-mini S&P 500'): 2131.0,
(Timestamp('2016-09-19 14:30:00'), 'Gold'): 1339.0999999999999,
(Timestamp('2016-09-19 14:30:00'),
'Henry Hub Natural Gas'): 4.8179999999999996,
(Timestamp('2016-09-19 14:30:00'), 'Lean Hogs'): 55.174999999999997,
(Timestamp('2016-09-19 14:30:00'),
'Light Sweet Crude Oil'): 49.719999999999999,
(Timestamp('2016-09-19 14:30:00'), 'Live Cattle'): 97.200000000000003,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Copper Index'): 2.2149999999999999,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Palladium Index'): 691.25,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Platinum Index'): 1039.0,
(Timestamp('2016-09-19 14:30:00'),
'Soybean Meal Futures'): 334.89999999999998,
(Timestamp('2016-09-19 14:30:00'), 'Soybean Oil Futures'): 34.5,
(Timestamp('2016-09-19 14:30:00'), 'Wheat Futures'): 494.25,
(Timestamp('2016-09-19 15:00:00'), '10 Year US Treasury Note'): 128.609375,
(Timestamp('2016-09-19 15:00:00'), '30 Day Fed Funds'): 98.885000000000005,
(Timestamp('2016-09-19 15:00:00'),
'Bloomberg Commodity Index'): 85.099999999999994,
(Timestamp('2016-09-19 15:00:00'), 'E-mini S&P 500'): 2128.0,
(Timestamp('2016-09-19 15:00:00'), 'Gold'): 1338.2},
'volume': {(Timestamp('2016-09-19 13:30:00'),
'10 Year US Treasury Note'): 30941.0,
(Timestamp('2016-09-19 13:30:00'), '30 Day Fed Funds'): 251.0,
(Timestamp('2016-09-19 13:30:00'), 'Bloomberg Commodity Index'): 0.0,
(Timestamp('2016-09-19 13:30:00'), 'E-mini S&P 500'): 164450.0,
(Timestamp('2016-09-19 13:30:00'), 'Gold'): 6173.0,
(Timestamp('2016-09-19 13:30:00'), 'Henry Hub Natural Gas'): 8462.0,
(Timestamp('2016-09-19 13:30:00'), 'Lean Hogs'): 1489.0,
(Timestamp('2016-09-19 13:30:00'), 'Light Sweet Crude Oil'): 30803.0,
(Timestamp('2016-09-19 13:30:00'), 'Live Cattle'): 2970.0,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Copper Index'): 3066.0,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Palladium Index'): 373.0,
(Timestamp('2016-09-19 13:30:00'), 'NYMEX Platinum Index'): 1014.0,
(Timestamp('2016-09-19 13:30:00'), 'Soybean Meal Futures'): 4978.0,
(Timestamp('2016-09-19 13:30:00'), 'Soybean Oil Futures'): 8493.0,
(Timestamp('2016-09-19 13:30:00'), 'Wheat Futures'): 7462.0,
(Timestamp('2016-09-19 14:00:00'), '10 Year US Treasury Note'): 40382.0,
(Timestamp('2016-09-19 14:00:00'), '30 Day Fed Funds'): 526.0,
(Timestamp('2016-09-19 14:00:00'), 'Bloomberg Commodity Index'): 1250.0,
(Timestamp('2016-09-19 14:00:00'), 'E-mini S&P 500'): 117841.0,
(Timestamp('2016-09-19 14:00:00'), 'Gold'): 4891.0,
(Timestamp('2016-09-19 14:00:00'), 'Henry Hub Natural Gas'): 3945.0,
(Timestamp('2016-09-19 14:00:00'), 'Lean Hogs'): 729.0,
(Timestamp('2016-09-19 14:00:00'), 'Light Sweet Crude Oil'): 44921.0,
(Timestamp('2016-09-19 14:00:00'), 'Live Cattle'): 1380.0,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Copper Index'): 3076.0,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Palladium Index'): 1062.0,
(Timestamp('2016-09-19 14:00:00'), 'NYMEX Platinum Index'): 624.0,
(Timestamp('2016-09-19 14:00:00'), 'Soybean Meal Futures'): 3007.0,
(Timestamp('2016-09-19 14:00:00'), 'Soybean Oil Futures'): 6114.0,
(Timestamp('2016-09-19 14:00:00'), 'Wheat Futures'): 3592.0,
(Timestamp('2016-09-19 14:30:00'), '10 Year US Treasury Note'): 32360.0,
(Timestamp('2016-09-19 14:30:00'), '30 Day Fed Funds'): 0.0,
(Timestamp('2016-09-19 14:30:00'), 'Bloomberg Commodity Index'): 0.0,
(Timestamp('2016-09-19 14:30:00'), 'E-mini S&P 500'): 76527.0,
(Timestamp('2016-09-19 14:30:00'), 'Gold'): 3831.0,
(Timestamp('2016-09-19 14:30:00'), 'Henry Hub Natural Gas'): 4526.0,
(Timestamp('2016-09-19 14:30:00'), 'Lean Hogs'): 406.0,
(Timestamp('2016-09-19 14:30:00'), 'Light Sweet Crude Oil'): 27306.0,
(Timestamp('2016-09-19 14:30:00'), 'Live Cattle'): 735.0,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Copper Index'): 1394.0,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Palladium Index'): 235.0,
(Timestamp('2016-09-19 14:30:00'), 'NYMEX Platinum Index'): 419.0,
(Timestamp('2016-09-19 14:30:00'), 'Soybean Meal Futures'): 3348.0,
(Timestamp('2016-09-19 14:30:00'), 'Soybean Oil Futures'): 3559.0,
(Timestamp('2016-09-19 14:30:00'), 'Wheat Futures'): 4125.0,
(Timestamp('2016-09-19 15:00:00'), '10 Year US Treasury Note'): 23938.0,
(Timestamp('2016-09-19 15:00:00'), '30 Day Fed Funds'): 0.0,
(Timestamp('2016-09-19 15:00:00'), 'Bloomberg Commodity Index'): 30.0,
(Timestamp('2016-09-19 15:00:00'), 'E-mini S&P 500'): 68578.0,
(Timestamp('2016-09-19 15:00:00'), 'Gold'): 2537.0}}
【问题讨论】:
-
无论如何都要尝试发布它。这可能是一个简单的格式问题。无论哪种方式,我都不想手动创建那个令人讨厌的数据框。最坏的情况,我编辑您的问题并查看/复制您的数据。最好的情况是它看起来很棒。中间情况是有人编辑了您的问题并为您修复了格式。
-
@piRSquared 不,我无法发布它。我收到一条来自 SO 的错误消息,表明该消息的代码过多。
-
然后,您需要减少代码以生成可以重现您的问题的最小示例。你不必做我说的任何事。但我愿意打赌,如果你这样做,有人会在很短的时间内回答你的问题。仍然有人可能。
-
您可以改为
df.head(20).to_dict()并在此处发布输出吗?以这种方式构建比使用该数据转储要容易得多。 -
@cᴏʟᴅsᴘᴇᴇᴅ 是的,我一开始就是这样做的,但无法发布。然而,作为一个编辑它确实有效。谢谢
标签: python pandas dataframe indexing multi-index