pyflink.dataframe.dataframe.DataFrame.with_column#
- DataFrame.with_column(name: str, expr: Expression | Callable[[DataFrame], Expression]) DataFrame[source]#
Add a new column or replace an existing column.
- Parameters:
name – Name of the new or existing column.
expr – Expression for the column value, or a callable that takes the DataFrame and returns an Expression.
- Returns:
A new DataFrame with the added/replaced column.
- Example::
>>> df.with_column("c", col("a") + col("b")) >>> df.with_column("c", lambda df: df["a"] + df["b"])