ray.data.aggregate.AbsMax#

class ray.data.aggregate.AbsMax(on: str | None = None, ignore_nulls: bool = True, alias_name: str | None = None, zero_factory: ~typing.Callable[[], ~ray.data.aggregate.SupportsRichComparisonType] = <function AbsMax.<lambda>>)[source]#

Bases: AggregateFnV2[SupportsRichComparisonType, SupportsRichComparisonType]

Defines absolute max aggregation.

Example

import ray
from ray.data.aggregate import AbsMax

ds = ray.data.range(100)
# Schema: {'id': int64}
ds = ds.add_column("group_key", lambda x: x % 3)
# Schema: {'id': int64, 'group_key': int64}

# Calculating the absolute maximum value per group:
result = ds.groupby("group_key").aggregate(AbsMax(on="id")).take_all()
# result: [{'group_key': 0, 'abs_max(id)': ...},
#          {'group_key': 1, 'abs_max(id)': ...},
#          {'group_key': 2, 'abs_max(id)': ...}]
Parameters:
  • on – The name of the column to calculate absolute maximum on. Must be provided.

  • ignore_nulls – Whether to ignore null values. Default is True.

  • alias_name – Optional name for the resulting column.

  • zero_factory – A callable that returns the initial “zero” value for the accumulator. For example, for a float column, this would be lambda: 0. Default is lambda: 0.

Methods

finalize

Transforms the final accumulated state into the desired output.