I have a data frame like this with multi index:
I have the following multiindex:
MultiIndex([('2019-09', 1617),
('2019-09', 1618),
('2019-09', 1619),
('2019-09', 1646),
('2019-09', 1655),
('2019-09', 1665),
('2019-09', 1670),
('2019-09', 1674),
('2019-09', 1681),
('2019-09', 1692),
('2019-09', 1739),
('2019-09', 1761),
('2019-09', 1768),
('2019-09', 1782),
('2019-10', 1619),
('2019-10', 1646),
('2019-10', 1782),
('2019-10', 1783),
('2019-10', 1790),
('2019-10', 1800),
('2019-10', 1815),
('2019-10', 1819),
('2019-10', 1826),
('2019-10', 1854),
('2019-10', 1867),
('2019-10', 1883),
('2019-10', 1884),
('2019-10', 1910),
('2019-10', 1916),
('2019-11', 1783),
('2019-11', 1910),
('2019-11', 1959),
('2019-11', 1960),
('2019-11', 1966),
('2019-11', 1986),
('2019-11', 2035),
('2019-11', 2071),
('2019-12', 1783),
('2019-12', 1962),
('2019-12', 2112),
('2019-12', 2118),
('2019-12', 2144),
('2019-12', 2162),
('2019-12', 2182),
('2019-12', 2205),
('2020-01', 1783),
('2020-01', 2112),
('2020-01', 2281),
('2020-01', 2287),
('2020-01', 2307),
('2020-01', 2314),
('2020-01', 2331),
('2020-01', 2333),
('2020-01', 2341),
('2020-01', 2342),
('2020-01', 2351),
('2020-01', 2362),
('2020-01', 2364),
('2020-01', 2388),
('2020-01', 2423),
('2020-02', 2304),
('2020-02', 2366),
('2020-02', 2388),
('2020-02', 2438),
('2020-02', 2987),
('2020-02', 2988),
('2020-02', 2991),
('2020-02', 3003),
('2020-02', 3040),
('2020-02', 3055),
('2020-02', 3071),
('2020-02', 3076),
('2020-02', 3086),
('2020-02', 3115),
('2020-03', 3126),
('2020-03', 3739),
('2020-03', 3748),
('2020-03', 3775)],
names=['createdAt_ym', 'eventId'])
I am trying to get all entries with '2020-02'
:
df.loc[('2020-02', 'createdAt_ym')]
KeyError: 'createdAt_ym'
I see that the names of the multiindex appear correctly, so I don't understand why I cannot index using
'createdAt_ym'