diff --git a/problem1.py b/problem1.py new file mode 100644 index 0000000..ea2d049 --- /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_sal=df.groupby('departmentId')['salary'].transform('max') + df=df[df['salary'] == max_sal] + return df[['name_y', 'name_x', 'salary']].rename(columns={'name_y': 'Department', 'name_x': 'Employee'}) \ No newline at end of file diff --git a/problem2.py b/problem2.py new file mode 100644 index 0000000..6f60c0a --- /dev/null +++ b/problem2.py @@ -0,0 +1,8 @@ +import pandas as pd + +def order_scores(scores: pd.DataFrame) -> pd.DataFrame: + scores=scores.sort_values('score',ascending=False) + scores['rank']=scores['score'].rank(method='dense',ascending=False) + return scores[['score','rank']] + + \ No newline at end of file