Tutorials References Exercises Videos Menu
Create Website Get Certified Upgrade

Pandas DataFrame join() Method

❮ DataFrame Reference


Example

Add the content of one DataFrame to another:

import pandas as pd

data1 = {
  "name": ["Sally", "Mary", "John"],
  "age": [50, 40, 30]
}

data2 = {
  "qualified": [True, False, False]
}

df1 = pd.DataFrame(data1)
df2 = pd.DataFrame(data2)

newdf = df1.join(df2)
Try it Yourself »

Definition and Usage

The join() method inserts column(s) from another DataFrame, or Series.


Syntax

dataframe.join(other, on, how, lsuffix, rsuffix, sort)

Parameters

The join, on, how, lsuffix , rsuffix, sort parameters are keyword arguments.

Parameter Value Description
other   Required. A DataFrame, a Series or a list of DataFrames.
on String
List
Optional. Specifies in what level to do the joining
how 'left'
'right'
'outer'
'inner'
Optional. Default 'left'. Specifies which index to use
lsuffix Sring Optional. Default '', Specifies a string to add for overlapping columns
rsuffix Sring Optional. Default '', Specifies a string to add for overlapping columns
sort True
False
Optional. Default False. Specifies whether to sort the DataFrame by the join key or not

Return Value

A new DataFrame, with the updated result.

This method does not change the original DataFrame.


❮ DataFrame Reference