Joins: Part 2

In my previous blog, we discussed inner and outer joins. For this blog, I would like to briefly explain left and right joins. Let’s take two DataFrames again:

df1

df2

To perform a left join on these two DataFrames, you would need to execute the following code:

df_join = df1.merge(df2, how ='left')

The result looks like this:

Unfortunately you do lose your index in the process, so you will have to reset that later.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store