Given a simple data frame
df = pd.DataFrame(np.random.rand(5,3))
I can select the records with the labels 1 and 3 using
df.loc[[1,3]]
But, if I change alter the index so it uses dates...
df.index = pd.date_range('1/1/2010', periods=5)
this no longer works:
df.loc[['2010-01-02', '2010-01-04']]
KeyError: "None of [['2010-01-02', '2010-01-04']] are in the [index]"
How can .loc be used with dates in this context?