Skip to main content

Pandas DataFrame Intersection Operation

In Pandas DataFrame Set Operation we can use merge() method to perform intersection operation. merge() function is a pre-defined function that can be used to do an intersection between two sets. It keeps the values present in both dataframe. This function takes both the dataframe as an argument.


import pandas as pd

A = pd.DataFrame ({"name":["Jack","Alice"],

print(A)#first dataframe


    name  Roll_No
0   Jack       13
1  Alice       15
B = pd.DataFrame ({"name":["Jack","Monica"],
print(B)#second dataframe


     name  Roll_No
0    Jack       13
1  Monica       19


   name  Roll_No
0  Jack       13
Submitted by devanshi.srivastava on February 15, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.