I have a spark dataframe as below
| a1 | a2 | a3 | a4 |
|---|---|---|---|
| A | 12 | 9 | 1 |
| B | 14 | 13 | 1 |
| C | 7 | 3 | 0 |
I want to create a new column A5 such with conditioning such as
if a1 = A then a5 = Car
if a2>0 then a5 = Bus
if a3>0 and a4 =1 then a5 = Bike
The desired output should as below
| a1 | a2 | a3 | a4 | a5 |
|---|---|---|---|---|
| A | 12 | 9 | 1 | Car |
| A | 12 | 9 | 1 | Bus |
| A | 12 | 9 | 1 | Bike |
| B | 14 | 13 | 1 | Bus |
| B | 14 | 13 | 1 | Bike |
| C | 7 | 3 | 0 | Bus |
Please help on how to add this new column. Thank you in advance