O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying the join semantics of a merge operation

The default type of join performed by pd.merge() is an inner join. To use another join method, specify the join type using the how parameter of the pd.merge() function (or the .merge() method). The valid options are:

  • inner: This is the intersection of keys from both DataFrame objects
  • outer: This is the union of keys from both DataFrame objects
  • left: This only uses keys from the left DataFrame
  • right: This only uses keys from the right DataFrame

As we have seen, an inner join is the default and it returns a merge of the data from both DataFrame objects only where the values match.

An outer join, in contrast, returns both the merge of the matched rows and the unmatched values from both the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required