I have a pyspark dataframe with this cols and values:
|employee|department|salary|
+--------+----------+------+
| James| Sales| 90000|
| Michael| Sales| 86000|
| Robert| Sales| 81000|
| Maria| Finance| 90000|
| Raman| Finance| 99000|
| Scott| Finance| 83000|
| Jeff| Marketing| 80000|
| Kumar| Marketing| 91000|
| Sarah| Marketing| 95000|
I want to have a dataframe with the employee with the highest salary for each department.
So my result will be :
|employee|department|highest salary|
+--------+----------+---------------+
| James| Sales| 90000|
| Raman| Finance| 99000|
| Sarah| Marketing| 95000|
I already tried multiple things with groupby but I don't know what to do.
Thank you for your help.