Skip to content

Commit cd51270

Browse files
iamAntimPalyanglbme
authored andcommitted
style: format code and docs with prettier
1 parent 984a554 commit cd51270

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

solution/0100-0199/0184.Department Highest Salary/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ Department 表:
9393
<!-- solution:start -->
9494

9595
### Python3
96+
9697
```python
9798
import pandas as pd
9899

99100
def department_highest_salary(employee: pd.DataFrame, department: pd.DataFrame) -> pd.DataFrame:
100101
# Merge the two tables on departmentId and department id
101102
merged = employee.merge(department, left_on='departmentId', right_on='id')
102-
103+
103104
# Find the maximum salary for each department
104105
max_salaries = merged.groupby('departmentId')['salary'].transform('max')
105-
106+
106107
# Filter employees who have the highest salary in their department
107108
top_earners = merged[merged['salary'] == max_salaries]
108-
109+
109110
# Select required columns and rename them
110111
result = top_earners[['name_y', 'name_x', 'salary']].copy()
111112
result.columns = ['Department', 'Employee', 'Salary']
112-
113+
113114
return result
114115
```
115116

116-
117117
### 方法一:等值连接 + 子查询
118118

119119
我们可以使用等值连接,将 `Employee` 表和 `Department` 表连接起来,连接条件为 `Employee.departmentId = Department.id`,然后使用子查询来找到每个部门的最高工资,最后使用 `WHERE` 子句来筛选出每个部门中薪资最高的员工。

solution/0100-0199/0184.Department Highest Salary/README_EN.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,27 +95,27 @@ Department table:
9595
<!-- solution:start -->
9696

9797
### Python3
98+
9899
```python
99100
import pandas as pd
100101

101102
def department_highest_salary(employee: pd.DataFrame, department: pd.DataFrame) -> pd.DataFrame:
102103
# Merge the two tables on departmentId and department id
103104
merged = employee.merge(department, left_on='departmentId', right_on='id')
104-
105+
105106
# Find the maximum salary for each department
106107
max_salaries = merged.groupby('departmentId')['salary'].transform('max')
107-
108+
108109
# Filter employees who have the highest salary in their department
109110
top_earners = merged[merged['salary'] == max_salaries]
110-
111+
111112
# Select required columns and rename them
112113
result = top_earners[['name_y', 'name_x', 'salary']].copy()
113114
result.columns = ['Department', 'Employee', 'Salary']
114-
115+
115116
return result
116117
```
117118

118-
119119
### Solution 1: Equi-Join + Subquery
120120

121121
We can use an equi-join to join the `Employee` table and the `Department` table based on `Employee.departmentId = Department.id`, and then use a subquery to find the highest salary for each department. Finally, we can use a `WHERE` clause to filter out the employees with the highest salary in each department.
@@ -173,8 +173,6 @@ FROM T
173173
WHERE rk = 1;
174174
```
175175

176-
177-
178176
<!-- tabs:end -->
179177

180178
<!-- solution:end -->

0 commit comments

Comments
 (0)