0

I have two dataframes ch2 and ch3 with an allele column ( I have more ch2 than ch3). I want to have the rows when both dataframes have the same value.

I have tried this code but every time I get FALSE as result. THANKS

for y in ch2.allele:
    print(y)
    i = ch3.allele
    print(i)
    testtt =(y in i)
    print (testt)
    if (testtt ==True):
        print ("ok")
Yad.yos
  • 45
  • 6
  • Just use: `ch2.merge(ch3, left_on='allele', right_on='allele')` – Mayank Porwal Jun 01 '22 at 14:10
  • Thank you for your answer But I don't want to join the two tables. I just want to get the rows where they have the same value of the column "allele". – Yad.yos Jun 01 '22 at 14:13
  • `I just want to get the rows where they have the same value of the column "allele".` That is exactly what joining two tables is. – Mayank Porwal Jun 01 '22 at 14:14
  • in fact i have two dataframes i can know just when both have the same value of a column but i absolutely do not want to join or concatenate them – Yad.yos Jun 01 '22 at 14:17
  • So you want the index of the matching rows in both dataframes, is it? – Mayank Porwal Jun 01 '22 at 14:24

0 Answers0