I\'m considering merge operations on dataframes each with a large number of columns. Don\'t want the result to have two columns with the same name. Am trying to view a list
Use numpy.intersect1d or intersection:
a = np.intersect1d(df2.columns, df1.columns) print (a) ['B' 'C'] a = df2.columns.intersection(df1.columns) print (a) Index(['B', 'C'], dtype='object')
Alternative syntax for the latter option:
df1.columns & df2.columns