Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 974 Bytes

_175. Combine Two Tables.md

File metadata and controls

40 lines (28 loc) · 974 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : May 22, 2024

Last updated : July 01, 2024


Related Topics : Database

Acceptance Rate : 76.91 %


Solutions

Python

import pandas as pd

def combine_two_tables(person: pd.DataFrame, address: pd.DataFrame) -> pd.DataFrame:
    return pd.merge(left=person, right=address, how='left', on='personId')[['firstName', 'lastName', 'city', 'state']]

SQL

SELECT firstName, lastName, city, state
    FROM Person LEFT OUTER JOIN Address ON Person.personId = Address.personId;