Pandas 오른쪽 안티조인

1 개요[ | ]

Pandas 오른쪽 안티조인

2 예시 1: 컬럼명 다른 경우[ | ]

Right-anti-join-operation.png

import pandas as pd
df1 = pd.DataFrame({'Date':['1/1/2020','1/2/2020','1/3/2020','1/4/2020'],'CountryID':[1,1,3,2],'Units': [40,25,30,35]})
df1
df2 = pd.DataFrame({'ID':[3,4],'County':['Panama','Spain']})
df2
temp = pd.merge(df1, df2, how='right', indicator=True, left_on='CountryID', right_on='ID')
temp.loc[temp._merge == 'right_only', :].drop(columns='_merge')

3 예시 2: 컬럼명 같은 경우[ | ]

import pandas as pd
df1 = pd.DataFrame({'Date':['1/1/2020','1/2/2020','1/3/2020','1/4/2020'],'CountryID':[1,1,3,2],'Units': [40,25,30,35]})
df1
df2 = pd.DataFrame({'CountryID':[3,4],'County':['Panama','Spain']})
df2
temp = pd.merge(df1, df2, how='right', indicator=True, on='CountryID')
temp.loc[temp._merge == 'right_only', :].drop(columns='_merge')

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}