downloader.entsoe.find_missing_intervals

downloader.entsoe.find_missing_intervals(index)

Find interior gaps in a datetime index.

Compares the index against the complete date range spanning its first and last timestamp – the same completeness notion as spotforecast2_safe.preprocessing.curate_data.basic_ts_checks, which raises on an incomplete index; this function reports the gaps instead so callers can repair them. The expected spacing is the most common step between consecutive timestamps, so the function works for hourly as well as 15-minute ENTSO-E data.

Parameters

Name Type Description Default
index pd.DatetimeIndex Sorted, duplicate-free datetime index to inspect. Indexes with fewer than 3 entries cannot contain a detectable interior gap and yield an empty list. required

Returns

Name Type Description
list[tuple[pd.Timestamp, pd.Timestamp]] list[tuple[pd.Timestamp, pd.Timestamp]]: One (first_missing, last_missing) pair per contiguous gap, both bounds inclusive. Empty list when the index is complete.

Raises

Name Type Description
ValueError If index is not sorted in increasing order.

Examples

import pandas as pd
from spotforecast2_safe.downloader.entsoe import find_missing_intervals

full = pd.date_range("2026-06-01", periods=96, freq="h", tz="UTC")
gappy = full.delete(list(range(48, 72)))  # June 3rd is missing
print(find_missing_intervals(gappy))
[(Timestamp('2026-06-03 00:00:00+0000', tz='UTC'), Timestamp('2026-06-03 23:00:00+0000', tz='UTC'))]