snowflake.snowpark.DataFrame.with_column¶
- DataFrame.with_column(col_name: str, col: Union[Column, TableFunctionCall], *, keep_column_order: bool = False, ast_stmt: Expr = None) DataFrame[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.30.0/snowpark-python/src/snowflake/snowpark/dataframe.py#L3920-L3990)¶
Returns a DataFrame with an additional column with the specified name
col_name. The column is computed by using the specified expressioncol.If a column with the same name already exists in the DataFrame, that column is replaced by the new column.
Example 1:
Example 2:
- Parameters:
col_name – The name of the column to add or replace.
col – The
Columnortable_function.TableFunctionCallwith single column output to add or replace.keep_column_order – If
True, the original order of the columns in the DataFrame is preserved when reaplacing a column.