File: merge.rst

package info (click to toggle)
pandas 2.2.3%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,784 kB
  • sloc: python: 422,228; ansic: 9,190; sh: 270; xml: 102; makefile: 83
file content (17 lines) | stat: -rw-r--r-- 516 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pandas DataFrames have a :meth:`~DataFrame.merge` method, which provides similar functionality. The
data does not have to be sorted ahead of time, and different join types are accomplished via the
``how`` keyword.

.. ipython:: python

   inner_join = df1.merge(df2, on=["key"], how="inner")
   inner_join

   left_join = df1.merge(df2, on=["key"], how="left")
   left_join

   right_join = df1.merge(df2, on=["key"], how="right")
   right_join

   outer_join = df1.merge(df2, on=["key"], how="outer")
   outer_join