Published
- 1 min read
identify the common columns between two dataframes pandas python
The solution for this is noted below
identify the common columns between two dataframes pandas python
Solution
a = np.intersect1d(df2.columns, df1.columns)
print (a)
['B' 'C']
a = df2.columns.intersection(df1.columns)
print (a)
Index(['B', 'C'], dtype='object')
Try other methods by searching on the site. That is if this doesn’t work