본문 바로가기

Algorithm/Python

[stratascratch] Salaries Differences(Python)

문제

Write a query that calculates the difference between the highest salaries found in the marketing and engineering departments. Output just the difference in salaries.

  • 마케팅 부서와 엔지니어링 부서 사이의 가장 높은 연봉 차를 계산하여 조회하기

코드

# Import your libraries
import pandas as pd

# Start writing code
db_employee.head()
df = pd.merge(db_employee, db_dept, how="inner", left_on="department_id", right_on="id")
abs(df[(df.department == 'marketing')]['salary'].max()-df[(df.department == 'engineering')]['salary'].max())

출처

반응형