We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c38f9f2 commit 287007aCopy full SHA for 287007a
src/solutions/s0176_second_highest_salary.py
@@ -0,0 +1,13 @@
1
+import pandas as pd
2
+
3
4
+def second_highest_salary(employee: pd.DataFrame) -> pd.DataFrame:
5
+ unique_salaries = employee["salary"].drop_duplicates()
6
+ second_highest = (
7
+ unique_salaries.nlargest(2).iloc[-1] if len(unique_salaries) >= 2 else None
8
+ )
9
10
+ if second_highest is None:
11
+ return pd.DataFrame({"SecondHighestSalary": [None]})
12
13
+ return pd.DataFrame({"SecondHighestSalary": [second_highest]})
0 commit comments