Joins: Part 2

Joe Ramirez
Apr 13, 2021

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.

--

--