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.
pd.merge(df1, df2, how)
A B C 0 3 efg Rahul 1 4 ghi Shubham
A B C 0 1 Geeks Nikhil 1 2 For Rishabh
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python | Pandas DataFrame.fillna() to replace Null values in dataframe
- Pandas Dataframe.to_numpy() - Convert dataframe to Numpy array
- Convert given Pandas series into a dataframe with its index as another column on the dataframe
- Python | Pandas TimedeltaIndex.intersection
- Python | Pandas Index.intersection()
- Make a Pandas DataFrame with two-dimensional list | Python
- Python | Intersection of two lists
- Intersection of two arrays in Python ( Lambda expression and filter function )
- Python | Intersection of two String
- Python | Intersection of two nested list
- Difference of two columns in Pandas dataframe
- Split a text column into two columns in Pandas DataFrame
- Combine two Pandas series into a DataFrame
- Concatenate two columns of Pandas dataframe
- Sort the Pandas DataFrame by two or more columns
- Python | Pandas DataFrame.reset_index()
- Python | Pandas dataframe.notna()
- Python | Pandas Dataframe.duplicated()
- Python | Pandas dataframe.notnull()
- Python | Pandas dataframe.round()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.