PolarsBackend#
- class eclypse.report.backends.polars_backend.PolarsBackend[source]#
Bases:
FrameBackendPolars eager implementation of the FrameBackend abstract base class.
Methods
__init__()Initialise the polars backend.
columns(df)Return the set of column names.
filter_eq(df, col, value)Filter rows where col equals value.
filter_events(df, col, events)Filter rows where col is contained in events.
filter_in(df, col, values)Filter rows where col is contained in values.
filter_range_step(df, col, start, stop, step)Filter rows where col is within a range and matches the given step.
is_empty(df)Return whether the DataFrame is empty.
max(df, col)Return the maximum value of a column as an int.
Attributes
- __init__()[source]#
Initialise the polars backend.
Imports polars lazily to keep it as an optional dependency.
- is_empty(df)[source]#
Return whether the DataFrame is empty.
- Parameters:
df (DataFrame) – The DataFrame to inspect.
- Returns:
True if the DataFrame has no rows, otherwise False.
- Return type:
bool
- columns(df)[source]#
Return the set of column names.
- Parameters:
df (DataFrame) – The DataFrame to inspect.
- Returns:
A set containing the DataFrame column names.
- Return type:
set[str]
- max(df, col)[source]#
Return the maximum value of a column as an int.
- Parameters:
df (DataFrame) – The DataFrame to inspect.
col (str) – The name of the column.
- Returns:
The maximum value as a Python int.
- Return type:
int
- filter_events(df, col, events)[source]#
Filter rows where col is contained in events.
- Parameters:
df (DataFrame) – The DataFrame to filter.
col (str) – The column name to test membership against.
events (Iterable[int]) – The allowed values for col.
- Returns:
A filtered DataFrame.
- Return type:
DataFrame
- filter_range_step(df, col, start, stop, step)[source]#
Filter rows where col is within a range and matches the given step.
- Parameters:
df (DataFrame)
col (str)
start (int)
stop (int)
step (int)
- Return type:
DataFrame