I am trying to use pd.date_range()
to create a DatetimeIndex
that spans over multiple days with a frequency in seconds. However, the time range for each day should be restricted between 05:00:00 and 22:00:00
Something along the lines of (doesn't work of course):
times_c = pd.date_range(start="2015-01-01",end="2015-01-10",freq="S")
mask_c = ((times_c.time < dt.datetime.strptime("22:00:00", "%H:%M:%S")) | (times_c.time > dt.datetime.strptime("05:00:00","%H:%M:%S")))
times_c = times_c[mask_c]
Use indexer_between_time
:
times_c[times_c.indexer_between_time('05:00:00', '22:00:00')]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With