Closed
Description
From SO:
import pandas as pd
import itertools
a = pd.period_range('2013Q1','2013Q4', freq='Q')
i = (1111, 2222, 3333)
idx = pd.MultiIndex.from_tuples(list(itertools.product(a, i)),
names=('Periode', 'CVR'))
df = pd.DataFrame(index=idx,
columns=('OMS', 'OMK','RES','DRIFT_IND','OEVRIG_IND','FIN_IND','VARE_UD','LOEN_UD','FIN_UD'))
Trying to select with a string gives a ValueError:
In [15]: df.loc[('2013Q1',1111),'OMS']
---------------------------------------------------------------------------
KeyError: ('2013Q1', 1111)
while it works with an explicit Period:
In [16]: df.loc[(pd.Period('2013Q1'),1111),'OMS']
Out[16]: nan
and it also works when not using multi-index notation (only accessing the first level): df.loc['2013Q1', 'OMS']
and this did work in 0.14.1.