I am trying to extract random multiple whole day data from pandas DateTimeIndex series, But it returns only the first hour data when the multiple days are passed as a list.
dt = pd.date_range('11-1-2022','11-4-2022',freq='6H').to_series()
When I want to extract single day it works fine
In [204]: dt['11-3-2022']
Out[204]:
2022-11-03 00:00:00 2022-11-03 00:00:00
2022-11-03 06:00:00 2022-11-03 06:00:00
2022-11-03 12:00:00 2022-11-03 12:00:00
2022-11-03 18:00:00 2022-11-03 18:00:00
Freq: 6H, dtype: datetime64[ns]
But when I want to extract multiple random days it only gives the first hour.
In [205]: dt[['11-1-2022','11-3-2022']]
Out[205]:
2022-11-01 2022-11-01
2022-11-03 2022-11-03
dtype: datetime64[ns]
How do I get all hours in the series for a given list of days.