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