Pandas: extracting multiple rows from DataFrame with list of DatetimeIndices

Viewed 353

I have a pandas Dataframe with the following index with seconds frequency:

DatetimeIndex(['2015-12-28 05:20:05', '2015-12-28 05:20:06',
               '2015-12-28 05:20:07', '2015-12-28 05:20:08',
               ...
               '2015-12-28 21:19:55', '2015-12-28 21:19:56',
               '2015-12-28 21:19:57', '2015-12-28 21:19:58']

I want to extract multiple rows at once, given a list of datetime strings. I tried:

df.loc[['2015-12-28 08:32:39', '2015-12-28 08:32:48']]

But I get the following error:

KeyError: "None of [['2015-12-28 08:32:39', '2015-12-28 08:32:48']] are in the [index]"
1 Answers
Related