我有一个带有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),我应该能够做到这一点。
有人有建议吗?
这里是重新创建数据帧的数据:
编辑:似乎我无法发布数据来重新创建这个数据帧,因为它使问题的代码看起来像代码太大了...希望这个问题仍然可以解决。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}}
答案 0 :(得分:1)
您应该可以通过将(idx[...], your_value)
的元组作为第一个参数传递给loc
来实现此目的。
prices.loc[(idx["2016-09-19 13:30:00":"2016-09-19 14:30:00"], xxx), :]
示例:
prices.loc[(idx["2016-09-19 13:30:00":"2016-09-19 14:30:00"], 'Gold'), :]
ID close high low open volume
2016-09-19 13:30:00 Gold 33824 1339.4 1341.2 1338.7 1341.2 6173.0
2016-09-19 14:00:00 Gold 33825 1339.1 1340.2 1338.6 1339.3 4891.0
2016-09-19 14:30:00 Gold 33826 1338.2 1339.7 1337.6 1339.1 3831.0