How to rename a column in a Dataframe in Apache Spark

Hey there! Welcome to ClearUrDoubt.com. In this post, we will look at withColumnRenamed() function in Apache Spark SQL API. withColumnRenamed(String columnName, String newColumnName) is used to rename a column in a Dataframe. Let’s look at the below code snippet in spark-shell for renaming a column: [crayon-662ec5885d5d4876651839/] sc.range(1,10).toDF() – creates an RDD with numbers from 1 to 10 … Continue reading How to rename a column in a Dataframe in Apache Spark