From c4645b7ca391e50d232130309287a3a5677e1ac5 Mon Sep 17 00:00:00 2001 From: Sakshi Asati Date: Fri, 27 Jun 2025 21:06:32 -0400 Subject: [PATCH] Done Pandas5 --- Department_highest_salary.py | 8 ++++++++ Rank_scores.py | 5 +++++ 2 files changed, 13 insertions(+) create mode 100644 Department_highest_salary.py create mode 100644 Rank_scores.py diff --git a/Department_highest_salary.py b/Department_highest_salary.py new file mode 100644 index 0000000..ac4144a --- /dev/null +++ b/Department_highest_salary.py @@ -0,0 +1,8 @@ +import pandas as pd + +def department_highest_salary(employee: pd.DataFrame, department: pd.DataFrame) -> pd.DataFrame: + df = employee.merge(department , left_on = 'departmentId' , right_on = 'id' , how = 'inner') + max_salary = df.groupby('departmentId')['salary'].transform('max') + df = df[df['salary'] == max_salary] + return df[['name_y' , 'name_x' ,'salary']].rename(columns = {'name_y' : 'Department','name_x' :'Employee'}) + \ No newline at end of file diff --git a/Rank_scores.py b/Rank_scores.py new file mode 100644 index 0000000..dc5d4c4 --- /dev/null +++ b/Rank_scores.py @@ -0,0 +1,5 @@ +import pandas as pd + +def order_scores(scores: pd.DataFrame) -> pd.DataFrame: + scores['rank'] = scores['score'].rank(method = 'dense' , ascending = False) + return scores[['score' , 'rank']].sort_values(by = ['score'] , ascending = False) \ No newline at end of file