랭귀지/pandas
join
유키공
2025. 6. 2. 13:40
import pandas as pd
df1 = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}, index=['x', 'y'])
df2 = pd.DataFrame({'A': [5, 6], 'C': [7, 8]}, index=['x', 'y'])
# Left join with drop=False
result = df1.join(df2.set_index('A', drop=False),
how='left', # 명시적으로 left join 지정
lsuffix='_left',
rsuffix='_right')
print(result)