Skip to content

pad

Pad(length, *, features=None)

Bases: Transform

Pad time-series features to the specified length.

Pad time-series features to the specified end-time by holding their last value for one more sample. This is useful for ensuring that all time-series features cover at least a time interval of the specified length. Time-series that are already longer than the specified will not be modified. The resulting features will not be equidistant in time. To achieve equidistant time-series, consider using the Resample transform after padding.

Initializes the Pad transform.

Parameters:

Name Type Description Default
length float

The length (time) to pad the features to. This is the minimum length that the features will have after applying this transform.

required
features None | str | Iterable[str]

The features to apply this transform to. Defaults to None, which will apply the transform to all time-series features.

None
Source code in src/flowcean/polars/transforms/pad.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def __init__(
    self,
    length: float,
    *,
    features: None | str | Iterable[str] = None,
) -> None:
    """Initializes the Pad transform.

    Args:
        length: The length (time) to pad the features to. This is the
            minimum length that the features will have after applying this
            transform.
        features: The features to apply this transform to. Defaults to
            `None`, which will apply the transform to all time-series
            features.
    """
    self.length = length
    self.features = (
        cast(
            "list[str]",
            ([features] if isinstance(features, str) else list(features)),
        )
        if features is not None
        else None
    )