In order to repeat the column in pyspark we will be using repeat() Function. We look at an example on how to repeat the string of the column in pyspark. Repeat the string of the column in pyspark using repeat() function.
If you perform a join in Spark and don't specify your join correctly you'll end up with duplicate column names.
I have a data frame in pyspark
like sample below. I would like to duplicate a column in the data frame and rename to another column name.
Name Age Rate
Aira 23 90
Ben 32 98
Cat 27 95
Desired output is :
Name Age Rate Rate2
Aira 23 90 90
Ben 32 98 98
Cat 27 95 95
How can I do it?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With