Skip to content

Commit

Permalink
docs: docstrings for aggregators
Browse files Browse the repository at this point in the history
  • Loading branch information
HLasse committed Feb 27, 2024
1 parent fe33a22 commit 32b6698
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/timeseriesflattener/aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,35 @@ def new_col_name(self, previous_col_name: str) -> str:


class MinAggregator(Aggregator):
"""Returns the minimum value in the look window."""

name: str = "min"

def __call__(self, column_name: str) -> pl.Expr:
return pl.col(column_name).min().alias(self.new_col_name(column_name))


class MaxAggregator(Aggregator):
"""Returns the maximum value in the look window."""

name: str = "max"

def __call__(self, column_name: str) -> pl.Expr:
return pl.col(column_name).max().alias(self.new_col_name(column_name))


class MeanAggregator(Aggregator):
"""Returns the mean value in the look window."""

name: str = "mean"

def __call__(self, column_name: str) -> pl.Expr:
return pl.col(column_name).mean().alias(self.new_col_name(column_name))


class CountAggregator(Aggregator):
"""Returns the count of non-null values in the look window."""

name: str = "count"

def __call__(self, column_name: str) -> pl.Expr:
Expand All @@ -48,6 +56,8 @@ def __call__(self, column_name: str) -> pl.Expr:

@dataclass(frozen=True)
class EarliestAggregator(Aggregator):
"""Returns the earliest value in the look window."""

timestamp_col_name: str
name: str = "earliest"

Expand All @@ -62,6 +72,8 @@ def __call__(self, column_name: str) -> pl.Expr:

@dataclass(frozen=True)
class LatestAggregator(Aggregator):
"""Returns the latest value in the look window"""

timestamp_col_name: str
name: str = "latest"

Expand All @@ -75,13 +87,17 @@ def __call__(self, column_name: str) -> pl.Expr:


class SumAggregator(Aggregator):
"""Returns the sum of all values in the look window."""

name: str = "sum"

def __call__(self, column_name: str) -> pl.Expr:
return pl.col(column_name).sum().alias(self.new_col_name(column_name))


class VarianceAggregator(Aggregator):
"""Returns the variance of the values in the look window"""

name: str = "var"

def __call__(self, column_name: str) -> pl.Expr:
Expand All @@ -106,6 +122,8 @@ def __call__(self, column_name: str) -> pl.Expr:

@dataclass(frozen=True)
class SlopeAggregator(Aggregator):
"""Returns the slope (i.e. the correlation between the timestamp and the value) in the look window."""

timestamp_col_name: str
name: str = "slope"

Expand Down

0 comments on commit 32b6698

Please sign in to comment.