Is it possible to remove rows if the values in the Block
column occurs at least twice which has different values in the ID
column?
My data looks like this:
ID | Block |
---|---|
1 | A |
1 | C |
1 | C |
3 | A |
3 | B |
In the above case, the value A
in the Block
column occurs twice, which has values 1 and 3 in the ID
column. So the rows are removed.
The expected output should be:
ID | Block |
---|---|
1 | C |
1 | C |
3 | B |
I tried to use the dropDuplicates
after the groupBy
, but I don't know how to filter with this type of condition. It appears that I would need a set
for the Block
column to check with the ID
column.