pyspark.pandas.DatetimeIndex.indexer_between_time

DatetimeIndex.indexer_between_time(start_time: Union[datetime.time, str], end_time: Union[datetime.time, str], include_start: bool = True, include_end: bool = True) → pyspark.pandas.indexes.base.Index[source]

Return index locations of values between particular times of day (example: 9:00-9:30AM).

Parameters
start_time, end_timedatetime.time, str

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”).

include_startbool, default True
include_endbool, default True
Returns
values_between_timeIndex of integers

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')