Suppose I have two dataframes:
data = {'model': ['B']}
df1 = pd.DataFrame (data, columns = ['model'])
df1
data = {'A': ['0.55', '0.49', '0.47',],
'B': ['0.48', '0.53', '0.54'],
'C': ['0.50', '0.51', '0.45']}
df2 = pd.DataFrame (data, columns = ['A', 'B', 'C'])
df2
I would like df2 to keep only the column where the name is equal to the value in df1. So the output would be that df2 only has one column in the dataframe - 'B'
How would I do this?
Thanks
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…