I have a dataframe that seems like a simple use case for a multi index: I have ISO week numbers and dates as an index, and I'd like to filter by a specific week. Following the instructions in the docs , it looks like I ought to be able to index just by passing a string of the week number. However, this passes me a Key Error.
MCVE:
data = {'foo': {('2016_32', '2016-08-07'): 0.14285714285714285,
('2016_32', '2016-08-08'): 0.14285714285714285,
('2016_32', '2016-08-09'): 0.14285714285714285,
('2016_32', '2016-08-10'): 0.14285714285714285,
('2016_32', '2016-08-11'): 0.14285714285714285,
('2016_32', '2016-08-12'): 0.14285714285714285,
('2016_32', '2016-08-13'): 0.14285714285714285,
('2016_36', '2016-09-04'): 0.14285714285714285,
('2016_36', '2016-09-05'): 0.14285714285714285,
('2016_36', '2016-09-06'): 0.14285714285714285,
('2016_36', '2016-09-07'): 0.14285714285714285,
('2016_36', '2016-09-08'): 0.14285714285714285,
('2016_36', '2016-09-09'): 0.14285714285714285},
'bar': {('2016_32', '2016-08-07'): np.nan,
('2016_32', '2016-08-08'): np.nan,
('2016_32', '2016-08-09'): np.nan,
('2016_32', '2016-08-10'): np.nan,
('2016_32', '2016-08-11'): np.nan,
('2016_32', '2016-08-12'): np.nan,
('2016_32', '2016-08-13'): np.nan,
('2016_36', '2016-09-04'): 0.0,
('2016_36', '2016-09-05'): 0.0,
('2016_36', '2016-09-06'): 0.0,
('2016_36', '2016-09-07'): 0.0,
('2016_36', '2016-09-08'): 0.0,
('2016_36', '2016-09-09'): 0.0}}
df = pd.DataFrame(data)
df['2016_32']
KeyError: '2016_32'