snowflake.snowpark.DataFrame.with_column_renamed¶
- DataFrame.with_column_renamed(existing: ColumnOrName, new: str) DataFrame [source]¶
Returns a DataFrame with the specified column
existing
renamed asnew
.Example:
>>> # This example renames the column `A` as `NEW_A` in the DataFrame. >>> df = session.sql("select 1 as A, 2 as B") >>> df_renamed = df.with_column_renamed(col("A"), "NEW_A") >>> df_renamed.show() ----------------- |"NEW_A" |"B" | ----------------- |1 |2 | -----------------
- Parameters:
existing – The old column instance or column name to be renamed.
new – The new column name.
with_column_renamed()
is an alias ofrename()
.