diff --git a/Department_Highest.txt b/Department_Highest.txt new file mode 100644 index 0000000..eb781a5 --- /dev/null +++ b/Department_Highest.txt @@ -0,0 +1,7 @@ +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 = employee.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','salary':'Salary'}) \ No newline at end of file diff --git a/Rank_Scores.txt b/Rank_Scores.txt new file mode 100644 index 0000000..68050e6 --- /dev/null +++ b/Rank_Scores.txt @@ -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('score',ascending = False) \ No newline at end of file