0

I have two dataframes

df = pd.DataFrame({'column':['A', 'B', 'C', 'C', 'D', 'E','A', 'F']})


df1 = pd.DataFrame({'column':['X','A','y','B','z','C','C','D','E','A','G','F'],
               'value':[2,4,3,5,6,1,7,2,8,9,10,11]})

How can I extract df from df1 with its value? Order doesn't matter; doesn't have to be row by row

Emily Nwo
  • 25
  • 5
  • `df1[df1['column'].isin(df['column'])]` – mozway May 18 '22 at 08:33
  • is it possible to do `df1[df['column A', 'column B'].isin(df['column A','column B'])` if I want to use 2 columns as criteria to compare? – Emily Nwo May 20 '22 at 05:18
  • If you want to match several columns you can `merge` on those to identify the elements. For only two columns, use several `isin` combined with `&` – mozway May 20 '22 at 05:20

0 Answers0