The withColumnRenamed()
command in Spark is used to rename an existing column in a DataFrame. This is particularly useful when you need to standardize column names, make them more descriptive, or align them with a specific naming convention.
PySpark:
Spark SQL:
PySpark:
Spark SQL:
Output:
PySpark:
Spark SQL:
Output:
PySpark:
Spark SQL:
Output:
PySpark:
Spark SQL:
Output:
PySpark:
Output:
PySpark:
Output:
withColumnRenamed()
command is used to rename one or more columns in a DataFrame.AS
in SELECT
statements.