diff --git a/Problem1.py b/Problem1.py new file mode 100644 index 0000000..09b7e5c --- /dev/null +++ b/Problem1.py @@ -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 = 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'}) diff --git a/Problem2.py b/Problem2.py new file mode 100644 index 0000000..54332b9 --- /dev/null +++ b/Problem2.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 = ['rank']) \ No newline at end of file