From the course: Data Analysis with Python and Pandas

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Left joins

Left joins

- [Instructor] So now let's go ahead and take a look at an example of a left join between the same tables we just performed an inner join on. So here we have our item_sales table. This one has 1,054,000 rows, and our right table has 83,000 rows. When we perform a left join, the only difference in our call to the merge method is the how argument we're specifying how equals left. But note that our row number is exactly the same as our left table. This is because a left join preserves all of the rows in our left table and will append NaN values where a match isn't found. So if we take a look at our return table, remember that there wasn't a date January 1st, 2016 in our transactions table. If we take a look at the value for transactions in the transactions column, all of those values are stored as NaNs, and ultimately it depends on the analysis we're performing. Maybe we do want a table where we only find matches, in which case we want to perform an inner join. But at least when we…

Contents