ray.data.expressions.col#

ray.data.expressions.col(name: str) ColumnExpr[source]#

Reference an existing column by name.

This is the primary way to reference columns in expressions. The returned expression will extract values from the specified column when evaluated.

Parameters:

name – The name of the column to reference

Returns:

A ColumnExpr that references the specified column

Example

>>> from ray.data.expressions import col
>>> # Reference columns in an expression
>>> expr = col("price") * col("quantity")
>>>
>>> # Use with Dataset.with_columns()
>>> import ray
>>> ds = ray.data.from_items([{"price": 10, "quantity": 2}])
>>> ds = ds.with_columns({"total": col("price") * col("quantity")})

PublicAPI (beta): This API is in beta and may change before becoming stable.