How do I compare the values of two columns from a data frame and skip other rows where there is no match between the two columns because the values are not on the same index position or row. i have tried several methods but none has worked so far. I want to match my second data frame to the the first data frame if the values they have are the same thing, I.e. the value of text and real-text column, when they are not the same it should ignore the unmatch one in the last data frame i have below
I have data frame that looks likes this
Text occurrence
0 my 4
1 name 6
2 is 7
3 very 3
4 popular 1
5 last 6
6 in 4
7 the 2
8 country 2
and another dataframe that looks like this:
real-text
0 my
1 name
2 is
3 very
4 popular
5 in
6 the
7 country
and now I want to merge the two where they actually match up and ignore any rows where there is no match this is what I have gotten so far but not getting the result i wanted :
Text real-text occurrence
0 my my 4
1 name name 6
2 is is 7
3 very very 3
4 popular popular 1
5 last in 6
6 in the 4
7 the country 2
8 country NaN 1
This is the result i'm expecting
Text real-text occurence
0 my my 4
1 name name 6
2 is is 7
3 very very 3
4 popular popular 1
6 in in 4
7 the the 2
8 country country 1
If you look at the expected data frame, it doesn't have the index position of 5 where there is no match between the two data frame
Thanks in advance as I'm still new to python