Intersection of two dataframe in Pandas - Python Last Updated : 26 Jul, 2020 Comments Improve Suggest changes Like Article Like Report Intersection of Two data frames in Pandas can be easily calculated by using the pre-defined function merge(). This function takes both the data frames as argument and returns the intersection between them. Syntax: pd.merge(df1, df2, how) Example 1: Python3 1== import pandas as pd # Creating Data frames df1 = {'A': [1, 2, 3, 4], 'B': ['abc', 'def', 'efg', 'ghi']} df2 = {'A': [1, 2, 3, 4 ], 'B': ['Geeks', 'For', 'efg', 'ghi'], 'C':['Nikhil', 'Rishabh', 'Rahul', 'Shubham']} d1 = pd.DataFrame(df1) d2 = pd.DataFrame(df2) # Calling merge() function int_df = pd.merge(d1, d2, how ='inner', on =['A', 'B']) print(int_df) Output: A B C 0 3 efg Rahul 1 4 ghi Shubham Example 2: Python3 1== import pandas as pd # Creating Data frames df1 = {'A': [1, 2, 3, 4], 'B': ['Geeks', 'For', 'efg', 'ghi']} df2 = {'A': [1, 2, 3, 4 ], 'B': ['Geeks', 'For', 'abc', 'cde'], 'C':['Nikhil', 'Rishabh', 'Rahul', 'Shubham']} d1 = pd.DataFrame(df1) d2 = pd.DataFrame(df2) # Calling merge() function int_df = pd.merge(d1, d2, how='inner', on=['A', 'B']) print(int_df) Output: A B C 0 1 Geeks Nikhil 1 2 For Rishabh Comment More infoAdvertise with us Next Article Intersection of two dataframe in Pandas - Python N nidhi_biet Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame Practice Tags : python Similar Reads Python | Pandas Index.intersection() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Index.intersection() function form the intersection of two Index objects. This 2 min read How to Merge Two Pandas DataFrames on Index Merging two pandas DataFrames on their index is necessary when working with datasets that share the same row identifiers but have different columns. The core idea is to align the rows of both DataFrames based on their indices, combining the respective columns into one unified DataFrame. To merge two 3 min read Python | Pandas dataframe.ne() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.Pandas dataframe.ne() function checks for inequality of a dataframe element with a cons 2 min read Find location of an element in Pandas dataframe in Python In this article, we will see how to find the position of an element in the dataframe using a user-defined function. Let's first Create a simple dataframe with a dictionary of lists. How to find an element in Pandas Dataframe?In a Pandas DataFrame, you can find the position of a specific element or c 3 min read Manipulating DataFrames with Pandas - Python Before manipulating the dataframe with pandas we have to understand what is data manipulation. The data in the real world is very unpleasant & unordered so by performing certain operations we can make data understandable based on one's requirements, this process of converting unordered data into 4 min read Python | Pandas dataframe.eq() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas dataframe.eq() is a wrapper used for the flexible comparison. It provides a con 3 min read Python | Pandas dataframe.equals() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas dataframe.equals() function is used to determine if two dataframe object in con 2 min read Python | Pandas dataframe.mask() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas dataframe.mask() function return an object of same shape as self and whose corr 3 min read Python | Intersection of two lists The task of finding the intersection of two lists involves identifying the common elements between them. This means we want to extract the values that appear in both lists, while ignoring any duplicates or values that are unique to each list. For example, if we have two lists [4, 9, 1, 17, 11] and [ 4 min read Python | Pandas dataframe.reindex_like() Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas dataframe.reindex_like() function return an object with matching indices to mys 3 min read Like