I want to change names of two columns using spark withColumnRenamed function. Of course, I can write:
data = sqlCont
Easiest way to do this is as follows:
Explanation:
from pyspark.sql import functions as F
(df
.select(*[F.col(c).alias(f"{c}_x") for c in df.columns])
.toPandas().head()
)
Hope this helps