I have the following datetime series:
0 2021-05-19 00:00:00
1 2021-05-19 00:00:00
2 2021-05-19 00:00:00
3 2021-05-19 00:00:00
4 2021-05-19 00:00:00
5 2021-05-19 23:59:00
6 2021-05-19 23:59:00
7 2021-05-19 23:59:00
8 2021-05-19 23:59:00
9 2021-05-19 23:59:00
Name: Ab, dtype: datetime64[ns]
If I use this selection method:
s[s.dt.date == datetime.date(2021, 5, 19)]
I get all data:
0 2021-05-19 00:00:00
1 2021-05-19 00:00:00
2 2021-05-19 00:00:00
3 2021-05-19 00:00:00
4 2021-05-19 00:00:00
5 2021-05-19 23:59:00
6 2021-05-19 23:59:00
7 2021-05-19 23:59:00
8 2021-05-19 23:59:00
9 2021-05-19 23:59:00
Name: Ab, dtype: datetime64[ns]
But if I use this short one:
s[s == '2021-05-19']
I get only midnight samples:
0 2021-05-19
1 2021-05-19
2 2021-05-19
3 2021-05-19
4 2021-05-19
Name: Ab, dtype: datetime64[ns]
What are the best practices to deal with such cases? Thank you!