How does PySpark and scala rename a DataFrame column?
admin
#spark #scala #program
There is way to rename filed in spark :
Using pyspark expression we can rename filed value
df = data.selectExpr("Name as name", "birthday as age")
df.show()
df.printSchema()
Using method withColumnRenamed in scala
df.withColumnRenamed("dob","DateOfBirth")
from pyspark.sql.functions import col
data = data.select(col("Name").alias("name"), col("birthday").alias("age"))
data.show()