Suppose I have this dataframe (call it df):

Here's what I want to do with the dataframe: 1. Select the rows that match with Col1 and Col2, if there are two rows for each id. 2. If there's only one row for the id, then select the row, even if the Col1 and Col2 do not match.
df = df[df['Col1'] == df['Col2']]
This code is wrong, because it doesn't satisfy the requirement 2 above. This is the result I want:
I would really appreciate it if someone could explain to me how to accomplish this! Thank you.