Forum Discussion

ToddChitt's avatar
ToddChitt
Super User
2 years ago
Solved

PySpark to rename a column in a dataframe

Hello. I am quite new to Spark Notebooks. I am using one to extract JSON data to save to tables in a Lakehouse. It works, but there are some slight issues. The data, being JSON, has nexted objects. I...
  • AndyDDC's avatar
    2 years ago

    Hi ToddChitt @can you try aliasing the column when using .select

     

    df_renamed = df.select(col("Name").alias("EmployeeName"), col("Department").alias("Dept")) 
    df_renamed.show()