Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Right Join | Joining Data
Data Manipulation using pandas

bookRight Join

Another type of join is the right one. This join is literally the same as the left join, but with swapped tables (i.e., to perform a right join of table1 to table2 is literally the same as left join of table2 to table1). To perform a right join, set the how = 'right' parameter.

So both data1.merge(data2, on = 'id', how = 'right') and data2.merge(data1, on = 'id', how = 'left') will return the same result (with changed order of columns).

12345678910
# Importing library import pandas as pd # Loading data data1 = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/f2947b09-5f0d-4ad9-992f-ec0b87cd4b3f/section5/data1.csv') data2 = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/f2947b09-5f0d-4ad9-992f-ec0b87cd4b3f/section5/data2.csv') # Perform a left join df_res = data1.merge(data2, on = 'id', how = 'right') print(df_res)
copy

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 3

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Awesome!

Completion rate improved to 2.56

bookRight Join

Swipe to show menu

Another type of join is the right one. This join is literally the same as the left join, but with swapped tables (i.e., to perform a right join of table1 to table2 is literally the same as left join of table2 to table1). To perform a right join, set the how = 'right' parameter.

So both data1.merge(data2, on = 'id', how = 'right') and data2.merge(data1, on = 'id', how = 'left') will return the same result (with changed order of columns).

12345678910
# Importing library import pandas as pd # Loading data data1 = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/f2947b09-5f0d-4ad9-992f-ec0b87cd4b3f/section5/data1.csv') data2 = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/f2947b09-5f0d-4ad9-992f-ec0b87cd4b3f/section5/data2.csv') # Perform a left join df_res = data1.merge(data2, on = 'id', how = 'right') print(df_res)
copy

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 3
some-alt