I have a pandas DataFrame with a DateTimeIndex
:
A B
2016-04-25 18:50:06 440.967796 201.049600
2016-04-25 18:50:13 441.054995 200.767034
2016-04-25 18:50:20 441.142337 200.484475
...
2016-07-27 18:50:06 440.967796 201.049600
2016-07-27 18:50:13 441.054995 200.767034
2016-07-27 18:50:20 441.142337 200.484475
I would like to extract all the data of a given date yyyy-mm-dd
using a list of dates: ['2016-04-25','2016-04-28',...]
I tried the following:
df[df.index.isin(['2016-04-25', '2016-04-26'])]
Empty DataFrame
I would like to retrieve all the data (data of the whole day) of the dates given in this list
You need remove times first by this solutions:
Another solution is compare
DatetimeIndex.date
, but necessary usenumpy.in1d
insteadisin
:Or compare strings created
DatetimeIndex.strftime
: