0

I have a dataframe (df)

x1 y1 value1 x2 y2 value2
1 150 blue 1 150 blue
2 151 red 2 151 green
3 152 green 3 152 green
4 153 yellow 4 153 blue
5 154 orange 5 154 yellow
6 155 blue 6 155 green
7 156 blue 7 156 blue

The x and y rows are always equal in the each other but value1 and value2 may differ. I want to create a new dataframe of instances where value1 != value2. As such:

x1 y1 value1 x2 y2 value2
2 151 red 2 151 green
4 153 yellow 4 153 blue
5 154 orange 5 154 yellow
6 155 blue 6 155 green

I have tried result_df = df.drop_duplicates(['value1', 'value2'], keep=False) but that does not seem to drop all duplicates

1 Answer 1

1
df.loc[(df.value1 != df.value2)]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.