Premium problem120. Bucket Salaries into Bands

Easy Locked

employees has columns employee_id and salary.

Add a salary_band column of plain strings:

  • "low" below 50,000
  • "medium" from 50,000 up to and including 100,000
  • "high" above 100,000

Return the original columns plus salary_band, index unchanged. Build it with a vectorised expression rather than iterating the rows.

Input

   employee_id  salary
0            1   30000
1            2   50000
2            3   75000
3            4  100000
4            5  150000

Output

   employee_id  salary salary_band
0            1   30000         low
1            2   50000      medium
2            3   75000      medium
3            4  100000      medium
4            5  150000        high

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)