snowflake.snowpark.DataFrame.withColumnRenamed

DataFrame.withColumnRenamed(existing: Union[Column, str], new: str) DataFrame[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/dataframe.py#L3717-L3774)

Returns a DataFrame with the specified column existing renamed as new.

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    |
-----------------
Copy
Parameters:
  • existing – The old column instance or column name to be renamed.

  • new – The new column name.

语言: 中文