Skip to content

mean

Mean(features, *, replace=False)

Bases: Transform

Replaces time-series features with their mean value.

Initializes the Mean transform.

Parameters:

Name Type Description Default
features str | Iterable[str]

The feature or features the mean should be calculated for.

required
replace bool

Whether to replace the original features with the transformed ones. If set to False, the default, the value will be added as a new feature named {feature}_mean.

False
Source code in src/flowcean/polars/transforms/mean.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def __init__(
    self,
    features: str | Iterable[str],
    *,
    replace: bool = False,
) -> None:
    """Initializes the Mean transform.

    Args:
        features: The feature or features the mean should be calculated
            for.
        replace: Whether to replace the original features with the
            transformed ones. If set to False, the default, the value will
            be added as a new feature named `{feature}_mean`.
    """
    self.features = [features] if isinstance(features, str) else features
    self.replace = replace