close

how to merge two data frames based on particular column in pandas python?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about how to merge two data frames based on particular column in pandas python in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

how to merge two data frames based on particular column in pandas python?

  1. how to merge two data frames based on particular column in pandas python?

    I think we can also use
    df1.merge(df2,on='Company')

  2. merge two data frames based on particular column in pandas python

    I think we can also use
    df1.merge(df2,on='Company')

Method 1

Use merge:

print (pd.merge(df1, df2, on='company'))

Sample:

print (df1)
  company standard
0    tata       A1
1     cts       A2
2    dell       A3

print (df2)
  company  return
0    tata      71
1    dell      78
2     cts      27
3     hcl      23

print (pd.merge(df1, df2, on='company'))
  company standard  return
0    tata       A1      71
1     cts       A2      27
2    dell       A3      78

Method 2

I think we can also use

df1.merge(df2,on='Company')

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read