unsafe_sorted_range_slice_idxs#
- openstef_core.utils.pandas.unsafe_sorted_range_slice_idxs(data: Series | Index, start: datetime | Timestamp | None, end: datetime | Timestamp | None) tuple[int, int][source]#
Get sorted slice indices for a datetime range.
Efficiently finds the start and end indices for slicing a sorted datetime series within a specified time range. Uses binary search for optimal performance on large datasets.
This function is particularly useful when working with large time series datasets where you need to quickly extract data for specific time windows without iterating through all data points.
- Parameters:
- Returns:
Tuple of (start_index, end_index) for slicing the data series.
- Return type:
Note
This function assumes that the input series is sorted in ascending order. It does not perform any checks to verify this, so it’s up to the caller to ensure that this invariant holds true.