ts_shape.events.quality.data_gap_analysis
| Name | Description |
|---|---|
DataGapAnalysisEvents | Quality: Data Gap Analysis |
DataGapAnalysisEvents
DataGapAnalysisEvents(
dataframe: pd.DataFrame,
signal_uuid: str,
*,
event_uuid: str = "quality:data_gap",
value_column: str = "value_double",
time_column: str = "systime"
) -> None
Bases: Base
Quality: Data Gap Analysis
Answer the question "where are the holes in my data?" by analyzing
gaps in a numeric signal's timestamps. Complements
:class:SignalQualityEvents (which detects individual missing-data
events) with pattern-level analysis: gap summaries, per-period
coverage, and interpolation-candidate identification.
Methods:
- detect_gaps: Locate all gaps longer than a threshold.
- gap_summary: Aggregate statistics across all gaps.
- coverage_by_period: Data coverage percentage per time window.
- interpolation_candidates: Gaps small enough to interpolate safely.
| Name | Description |
|---|---|
detect_gaps | Locate all gaps longer than min_gap. |
gap_summary | Aggregate statistics across all gaps. |
coverage_by_period | Data coverage percentage per time window. |
interpolation_candidates | Identify gaps small enough to safely interpolate. |
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format timeseries frame (one row per sample, uuid identifies the signal). | required |
signal_uuid | str | UUID of the signal to analyze. | required |
event_uuid | str | UUID stamped on emitted events. | 'quality:data_gap' |
value_column | str | Column holding the signal values. | 'value_double' |
time_column | str | Timestamp column. | 'systime' |
detect_gaps
detect_gaps(min_gap: str | pd.Timedelta | None = None) -> pd.DataFrame
Locate all gaps longer than min_gap.
A gap is a step between two consecutive samples strictly longer than
min_gap: regular 10-minute sampling with min_gap="10min" has
no gaps.
| Name | Type | Description | Default |
|---|---|---|---|
min_gap | str | Timedelta | None | Gap threshold (e.g. '5s', '1min', '1h'). None (default) is twice the median positive sampling interval, the rule of :meth:coverage_by_period, so a regularly sampled signal has no gaps. A zero-length step (duplicate timestamp) is never a gap, even with min_gap="0s". | None |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, uuid, |
DataFrame | source_uuid, gap_duration_seconds, samples_before_gap, |
DataFrame | samples_after_gap. gap_duration_seconds equals |
DataFrame | duration_seconds. |
gap_summary
gap_summary(min_gap: str | pd.Timedelta | None = None) -> pd.DataFrame
Aggregate statistics across all gaps.
| Name | Type | Description | Default |
|---|---|---|---|
min_gap | str | Timedelta | None | Gap threshold, as in :meth:detect_gaps (None: twice the median sampling interval). | None |
| Type | Description |
|---|---|
DataFrame | Single-row DataFrame with columns: total_gaps, total_missing_seconds, |
DataFrame | longest_gap_seconds, shortest_gap_seconds, mean_gap_seconds, |
DataFrame | data_span_seconds, gap_fraction. data_span_seconds is the |
DataFrame | time from the first to the last sample, with or without gaps. |
DataFrame | Without gaps total_missing_seconds, longest_gap_seconds |
DataFrame | and gap_fraction are 0 and shortest_gap_seconds / |
DataFrame | mean_gap_seconds are NaN (there is no gap to measure). |
coverage_by_period
coverage_by_period(
window: str = "1h", min_gap: str | pd.Timedelta | None = None
) -> pd.DataFrame
Data coverage percentage per time window.
For each window, reports how much of the window actually contains
data: the time the data covers minus any internal gaps. The data
covers first sample, last sample + one sampling step), the
sampling step being the median positive interval between
consecutive samples (the last sample holds for one step, as every
other sample holds until the next one; a signal without a positive
step covers no time after its last sample). Time of an edge window
before the first sample or after that end counts as missing, so
data 10:30:00-11:29:59 at 1 s reads 50 % in both hourly windows --
the same as SignalQualityEvents.data_completeness.
| Name | Type | Description | Default |
|---|---|---|---|
window | [str | Resample window (e.g. '1h', '1D', '15min'). | '1h' |
min_gap | str | Timedelta | None | Gap threshold, as in :meth:detect_gaps: a step strictly longer than it is a gap. Defaults to 2x the median sampling interval (auto-detected). | None |
| Name | Type | Description |
|---|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, uuid, | |
DataFrame | source_uuid, sample_count, coverage_pct, gap_count, | |
DataFrame | gap_seconds. end is the next period start. | |
DataFrame | gap_seconds includes the missing edge time of the first and | |
DataFrame | last window; gap_count counts only the internal gaps (those | |
of | DataFrame | meth:detect_gaps) overlapping the window. |
interpolation_candidates
interpolation_candidates(
max_gap: str = "10s", min_gap: str = "0s"
) -> pd.DataFrame
Identify gaps small enough to safely interpolate.
| Name | Type | Description | Default |
|---|---|---|---|
max_gap | str | Maximum gap duration to consider for interpolation. | '10s' |
min_gap | str | Minimum gap duration (ignore trivially small gaps). A zero-length step (duplicate timestamp) is never a gap. | '0s' |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, uuid, |
DataFrame | source_uuid, gap_duration_seconds, value_before, value_after, |
DataFrame | value_jump, safe_to_interpolate. |
DataFrame | safe_to_interpolate is True when the value jump across the |
DataFrame | gap is within 2 standard deviations of the signal. |