Articles → Pandas → Join Function In Dataframe In Pandas

Join Function In Dataframe In Pandas






Purpose





Example


import pandas as pd


# Create a dictionary
dict1 = {
        'company':['Google', 'Microsoft', 'Apple', 'Google', 'Microsoft', 'Apple'],
        'year': [2017, 2017, 2017, 2018, 2018, 2018],
        'Profit':[20000,40000,60000,80000,70000,50000]
       }

dict2 = {
        'company1':['Disney', 'Walmart', 'AT&T', 'Disney', 'Walmart', 'AT&T'],
        'year1': [2017, 2017, 2017, 2018, 2018, 2018],
        'Profit1':[10000,20000,30000,40000,50000,60000]
       }


# Create a dataframe
df1 = pd.DataFrame(dict1, index=[0,1,2,3,4,5])
df2 = pd.DataFrame(dict2, index=[0,1,2,3,4,5])

# join
df1.join(df2)





Output


Picture showing the output of the Join function in dataframe in pandas
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, April 30, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250