【Python】pandas로 2개의 테이블을 join한다
무엇을 하고 싶은가
아래의 테이블 2개를 ID를 바탕으로 1개로 하고 싶다.

어떻게 할까
pd.merge(Table_A,Table_B,how="XXXX",on="ID")
how="XXXX"로 조인 방법을 선택할 수 있습니다.
how="inner" (inner join)
두 테이블에 공통된 ID를 추출하고 조인합니다.

pd.merge(Table_A,Table_B,how="inner",on="ID")
결과

how="outer" (outer join)
두 테이블의 모든 ID를 추출하고 조인합니다.

pd.merge(Table_A,Table_B,how="outer",on="ID")
결과

데이터가 존재하지 않는 곳은 NaN입니다.
how="left" (left join)
왼쪽 테이블의 ID만 조인합니다.

pd.merge(Table_A,Table_B,how="left",on="ID")
결과

how="right" (right join)
오른쪽 테이블의 ID만 조인합니다.

pd.merge(Table_A,Table_B,how="right",on="ID")

끝
벤 다이어그램으로 쓰고 있는 기사가 적었기 때문에, 가능한 한 전면에 밀어냈습니다.
Reference
이 문제에 관하여(【Python】pandas로 2개의 테이블을 join한다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/sino20023/items/7bb790dd9d75930c9cc3
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
pd.merge(Table_A,Table_B,how="XXXX",on="ID")
how="XXXX"로 조인 방법을 선택할 수 있습니다.
how="inner" (inner join)
두 테이블에 공통된 ID를 추출하고 조인합니다.

pd.merge(Table_A,Table_B,how="inner",on="ID")
결과

how="outer" (outer join)
두 테이블의 모든 ID를 추출하고 조인합니다.

pd.merge(Table_A,Table_B,how="outer",on="ID")
결과

데이터가 존재하지 않는 곳은 NaN입니다.
how="left" (left join)
왼쪽 테이블의 ID만 조인합니다.

pd.merge(Table_A,Table_B,how="left",on="ID")
결과

how="right" (right join)
오른쪽 테이블의 ID만 조인합니다.

pd.merge(Table_A,Table_B,how="right",on="ID")

끝
벤 다이어그램으로 쓰고 있는 기사가 적었기 때문에, 가능한 한 전면에 밀어냈습니다.
Reference
이 문제에 관하여(【Python】pandas로 2개의 테이블을 join한다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/sino20023/items/7bb790dd9d75930c9cc3
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(【Python】pandas로 2개의 테이블을 join한다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/sino20023/items/7bb790dd9d75930c9cc3텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)