lair.clock.regular_times_to_intervals#
- lair.clock.regular_times_to_intervals(times, time_step='monthly', closed='left')[source]#
Convert an array of regular times to intervals of the specified length.
- Parameters:
times (np.array) – A numpy array of datetime64 values indicating the start of each interval.
time_step (str, optional) – The interval step (‘hourly’, ‘daily’, ‘monthly’, ‘annual’). Determines the length of each interval. Default is ‘monthly’.
closed (str, optional) – Defines if the interval is closed on the ‘left’, ‘right’, ‘both’, or ‘neither’. Default is ‘left’.
- Returns:
pd.IntervalIndex – An index with intervals covering the specified time range.
- Raises:
ValueError – If time_step is not one of ‘hourly’, ‘daily’, ‘monthly’, or ‘annual’.
- Return type: