Ramesh
Ramesh

Reputation: 1593

Dataframe column with two different names

I want to know if a a spark data frame can have two different names to a column.

I knew that by using "withColumn" i can add a new column but i do not want to add a new column to the data frame, but i just want to have alias name to the existing column in a data frame.

Example If there is a data frame with 3 columns "Col1, Col2, Col3".

So can anyone please let me know if i can give a alias name to Col3 so that i can retrieve the data of 'Col3' with name "Col4" as well.

Upvotes: 0

Views: 137

Answers (1)

Anders Elmgren
Anders Elmgren

Reputation: 658

EDIT: possible duplicate: Usage of spark DataFrame "as" method

It looks like there are several ways depending on the spark library and client library you're using.

Upvotes: 0

Related Questions