Skip to content

Latest commit

 

History

History
27 lines (24 loc) · 987 Bytes

1378. Replace Employee ID With The Unique Identifier.md

File metadata and controls

27 lines (24 loc) · 987 Bytes

1378. Replace Employee ID With The Unique Identifier

Question Link

Intuition

  • how:
    • inner(default): combine 2 table, dropping all the null
    • outer: conbine 2 table and use NaN to fulfill the blank, keeping all null
    • left: remain the left table's content, if the right one can't fit the left one properly, use NaN to fulfill the right table, keeping all null
    • right: just like left
  • on: choose the index

Pandas Code

import pandas as pd

def replace_employee_id(employees: pd.DataFrame, employee_uni: pd.DataFrame) -> pd.DataFrame:
    a=pd.merge(employees,employee_uni,how='left',on='id')
    return a[['unique_id', 'name']]

SQL Code

# Write your MySQL query statement below
select unique_id, name from Employees as e
left join EmployeeUNI as c
on e.id = c.id