I am trying to add a set of string values (Business, Casual) to a column=category in spark dataframe.
My dataframe is :
+----------+----+--------+
| source|live|category|
+----------+----+--------+
| Ford| Y| |
| Ford| Y| |
| Caddilac| Y| |
| Caddilac| Y| |
| Chevrolet| Y| |
| Chevrolet| Y| |
| Skoda| Y| |
| Skoda| Y| |
| Fiat| Y| |
| Fiat| Y| |
|Alfa Romeo| Y| |
|Alfa Romeo| Y| |
+----------+----+--------+
What I am working to get is a set of repeated values in a new/existing column:
| source|live|category|
+----------+----+--------+
| Ford| Y|Business|
| Ford| Y| Casual|
| Caddilac| Y|Business|
| Caddilac| Y| Casual|
| Chevrolet| Y|Business|
| Chevrolet| Y| Casual|
| Skoda| Y|Business|
| Skoda| Y| Casual|
| Fiat| Y|Business|
| Fiat| Y| Casual|
|Alfa Romeo| Y|Business|
|Alfa Romeo| Y| Casual|
+----------+----+--------+
I have tried to add the "category" column using withColumn and lit() but it takes just 1 value in argument. I also tried the explode(array()) but it multiplies the table to double rows.
The values in "category" column are constant and repeated , and not dependent on any other criteria
Any help would be appreciated. Thanks