From bdfc76759cc4616052f784aa8affff6e265cd19e Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Sun, 2 Mar 2025 18:50:35 -0600 Subject: [PATCH 1/4] Create Nth Highest Salary --- Nth Highest Salary | 1 + 1 file changed, 1 insertion(+) create mode 100644 Nth Highest Salary diff --git a/Nth Highest Salary b/Nth Highest Salary new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Nth Highest Salary @@ -0,0 +1 @@ + From f66cd34cbc7da5930550f25a14e0766fa5be536c Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Sun, 2 Mar 2025 18:50:53 -0600 Subject: [PATCH 2/4] Create Second Highest Salary --- Second Highest Salary | 1 + 1 file changed, 1 insertion(+) create mode 100644 Second Highest Salary diff --git a/Second Highest Salary b/Second Highest Salary new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Second Highest Salary @@ -0,0 +1 @@ + From a9ae94abb5d72ee9318c7b0d0a5dcb601520478b Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Mon, 3 Mar 2025 17:26:17 -0600 Subject: [PATCH 3/4] Update Nth Highest Salary --- Nth Highest Salary | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Nth Highest Salary b/Nth Highest Salary index 8b13789..403edb1 100644 --- a/Nth Highest Salary +++ b/Nth Highest Salary @@ -1 +1,10 @@ +import pandas as pd + +def nth_highest_salary(employee: pd.DataFrame, N: int) -> pd.DataFrame: + df =employee['salary'].drop_duplicates().sort_values(ascending=False) + if N>len(df) or N<=0: + return pd.DataFrame({f'getNthHighestSalary({N})': [None]}) + else: + df2 = df.iloc[N-1] + return pd.DataFrame({f'getNthHighestSalary({N})':[df2]}) From df5d93f1a7d8c2b92088e90522451130a46b204e Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Mon, 10 Mar 2025 20:44:36 -0500 Subject: [PATCH 4/4] Update Second Highest Salary --- Second Highest Salary | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Second Highest Salary b/Second Highest Salary index 8b13789..490e53f 100644 --- a/Second Highest Salary +++ b/Second Highest Salary @@ -1 +1,7 @@ +import pandas as pd + +def second_highest_salary(employee: pd.DataFrame) -> pd.DataFrame: + unique_salaries = employee['salary'].drop_duplicates().nlargest(2) #multiple entries avoided + second_highest = unique_salaries.iloc[1] if len(unique_salaries) > 1 else None #to find out the seond highest salary + return pd.DataFrame({'SecondHighestSalary': [second_highest]}) #renaming the column