How to update rows in DataFrame(Pyspark, not scala) where the update should happen on certain conditions? We dont know how many conditions will there be nor what they are during design time, so the conditions and the update values are to be applied at runtime. Sample DataFrame.
Table T1:
| Emp_LName | Emp_FName | Sal | Sal_Grade |
| -------- | -------------- |-------------- |------------- |
| Smith | Bob |100000 |B |
| Barnes | Jim |90000 |B |
| Rogers | Eric |120000 |A |
| Carson | Ben |45000 |C |
df_source = spark.sql("Select * from T1)
lst_Conditions =[(Sal= 45000,Sal_Grade=E),(E_Name='Bob',E_Name='Robert),(One more candition),...].
(Basically the conditions are to be interpreted as 'Where Sal=45000, Then set Sal_Grade=E).
How do I write code for each condition to update the dataframe? Any help is appreciated.
Thank you R