AsList#
- class ray.data.aggregate.AsList(on: str, alias_name: str | None = None, ignore_nulls: bool = False)[source]#
Bases:
AggregateFnV2[List,List]Listing aggregation combining all values within the group into a single list element.
Example
# Skip testing b/c this example require proper ordering of the output # to be robust and not flaky import ray from ray.data.aggregate import AsList ds = ray.data.range(10) # Schema: {'id': int64} ds = ds.add_column( "group_key", lambda batch: batch["id"].astype("int64") % 3 ) # Schema: {'id': int64, 'group_key': int64} # Listing all elements per group: result = ds.groupby("group_key").aggregate(AsList(on="id")).take_all() # result: [{'group_key': 0, 'list(id)': [0, 3, 6, 9]}, # {'group_key': 1, 'list(id)': [1, 4, 7]}, # {'group_key': 2, 'list(id)': [2, 5, 8]}
- Parameters:
Methods
Transforms the final accumulated state into the desired output.
Return the agg name (e.g., 'sum', 'mean', 'count').
Return the PyArrow
Fieldthis aggregator produces.