<aside> 💡 Data can be in multiple tables; this section is for skills on merging tables.

</aside>

Relationships between tables

One-to-one relationship

Every row in the left table is related to only one row in the right table.

One-to-many relationship

Every row in left table is related to one or more rows in the right table. When merge the result table will probably have more rows than the original table.

Basic Joins Types

Inner Join

combine = left.merge(right, on='key')

Suffix

<aside> 💡 If a table have the same column name, a _x and _y will be concat with the original name. To change the behaviour, we may want to add the suffixes attribute to the merge() method.

</aside>

# replace the _x and _y with the name you want.
combine = left.merge(right, on='key', suffixes=('_left', '_right'))

Merging multiple columns

# merge on multiple columns
left.merge(right, on=['col1', 'col2'])

Merging multiple tables