snowflake.snowpark.DataFrame.withColumn¶
- DataFrame.withColumn(col_name: str, col: Union[Column, TableFunctionCall], *, keep_column_order: bool = False, ast_stmt: Expr = None) DataFrame[source]¶
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.