How do you add a new column to a DataFrame in PySpark?
Asked in the Technical - PySpark stage.
Write the answer as if you are modifying a DataFrame that already contains employee payroll data. Show how to create one additional column derived from existing fields.
annual_bonus| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee full name |
| department | VARCHAR(50) | Employee department |
| monthly_salary | DECIMAL(10,2) | Monthly salary amount |