DatetimeIndex.
indexer_between_time
Return index locations of values between particular times of day (example: 9:00-9:30AM).
Time passed either as object (datetime.time) or as string in appropriate format (“%H:%M”, “%H%M”, “%I:%M%p”, “%I%M%p”, “%H:%M:%S”, “%H%M%S”, “%I:%M:%S%p”,”%I%M%S%p”).
Examples
>>> psidx = ps.date_range("2000-01-01", periods=3, freq="T") >>> psidx DatetimeIndex(['2000-01-01 00:00:00', '2000-01-01 00:01:00', '2000-01-01 00:02:00'], dtype='datetime64[ns]', freq=None)
>>> psidx.indexer_between_time("00:01", "00:02").sort_values() Int64Index([1, 2], dtype='int64')
>>> psidx.indexer_between_time("00:01", "00:02", include_end=False) Int64Index([1], dtype='int64')
>>> psidx.indexer_between_time("00:01", "00:02", include_start=False) Int64Index([2], dtype='int64')