I have the following dataframe:
ID Location Valid
1 Avenue Yes
1 Block No
2 Avenue Yes
3 Street No
3 Street No
4 Av. Yes
4 Street No
4 Av. Yes
I need to find a way to filter this dataframe returning all duplicated rows (by ID) that have a different value in the "Location" column . If the ID has different value, return all columns with that ID. If it appears 3 times or more in the data, if a single location is different, return all rows, resulting in this data:
ID Location Valid
1 Avenue Yes
1 Block No
4 Av. Yes
4 Street No
4 Av. Yes
What is the best way to perform this operation? Thanks!