ray.data.aggregate.Max#

class ray.data.aggregate.Max(on: str | None = None, ignore_nulls: bool = True, alias_name: str | None = None)[source]#

Bases: AggregateFnV2

Defines max aggregation.

Example

import ray
from ray.data.aggregate import Max

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

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

  • ignore_nulls – Whether to ignore null values. If True (default), nulls are skipped. If False, the maximum will be null if any value in the group is null (for most data types, or follow type-specific comparison rules with nulls).

  • alias_name – Optional name for the resulting column.

Methods

finalize

Transforms the final accumulated state into the desired output.