I want to combine the following two tables into one based on the ID.
pd.merge(Table_A,Table_B,how="XXXX",on="ID")
You can select the joining method with how = "XXXX".
how="inner" (inner join) Extract and join the IDs that are common to the two tables.
pd.merge(Table_A,Table_B,how="inner",on="ID")
result
how="outer" (outer join) Extract and join all the IDs of the two tables.
pd.merge(Table_A,Table_B,how="outer",on="ID")
result
Where there is no data, it is NaN.
how="left" (left join) Join only the IDs of the table on the left.
pd.merge(Table_A,Table_B,how="left",on="ID")
result
how="right" (right join) Join only the IDs of the table on the right.
pd.merge(Table_A,Table_B,how="right",on="ID")
Since there were few articles written in Venn diagrams, I pushed it out as much as possible.
Recommended Posts