I am trying to find the intersect of three dataframes, however the pd.intersect1d does not like to use three dataframes.
import numpy as np
import pandas as pd
df1 = pd.DataFrame(np.random.randint(0,10,size=(10, 4)), columns=list('ABCD'))
df2 = pd.DataFrame(np.random.randint(0,10,size=(10, 4)), columns=list('BCDE'))
df3 = pd.DataFrame(np.random.randint(0,10,size=(10, 4)), columns=list('CDEF'))
inclusive_list = np.intersect1d(df1.columns, df2.columns, df3.columns)
Error:
ValueError: The truth value of a Index is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
The inclusive_list should only include column names C & D. Any help would be appreciated. Thank you.