Subsetting dataframe by same values in two columns
Question:
I have a dataframe that looks like below:
code_1
code_2
a1
a1
a2
a1
b1
b2
b3
b3
What I want to do here is that I want to subset the dataframe by selecting the rows that have same values in ‘code_1’ and ‘code_2’
The final output would look like below:
code_1
code_2
a1
a1
b3
b3
Thank you
Answers:
I have a dataframe that looks like below:
code_1 | code_2 |
---|---|
a1 | a1 |
a2 | a1 |
b1 | b2 |
b3 | b3 |
What I want to do here is that I want to subset the dataframe by selecting the rows that have same values in ‘code_1’ and ‘code_2’
The final output would look like below:
code_1 | code_2 |
---|---|
a1 | a1 |
b3 | b3 |
Thank you