diff --git a/Problem1.py b/Problem1.py new file mode 100644 index 0000000..0fe8535 --- /dev/null +++ b/Problem1.py @@ -0,0 +1,12 @@ +import pandas as pd + +def nth_highest_salary(employee: pd.DataFrame, N: int) -> pd.DataFrame: + result_set = set() + for i in range(len(employee)): + salary = employee['salary'][i] + result_set.add(salary) + df = pd.DataFrame(result_set,columns = ['getNthHighestSalary']).sort_values(by = ['getNthHighestSalary'],ascending=False) + if N>len(df) or N<=0: + return pd.DataFrame({f'getNthHighestSalary({N})': [None]}) + else: + return pd.DataFrame({f'getNthHighestSalary({N})': df.iloc[N-1]}) \ No newline at end of file diff --git a/Problem2.py b/Problem2.py new file mode 100644 index 0000000..b8c84ca --- /dev/null +++ b/Problem2.py @@ -0,0 +1,12 @@ +import pandas as pd + +def second_highest_salary(employee: pd.DataFrame) -> pd.DataFrame: + result_set = set() + for i in range(len(employee)): + salary = employee['salary'][i] + result_set.add(salary) + df = pd.DataFrame(result_set,columns = ['SecondHighestSalary']).sort_values(by = ['SecondHighestSalary'],ascending=False) + if len(df)< 2: + return pd.DataFrame({f'SecondHighestSalary': [None]}) + else: + return pd.DataFrame({f'SecondHighestSalary': df.iloc[1]}) \ No newline at end of file