I need to identify/select/print the duplicate values in a field depending on the values of another one.
Example:
Field1 | Field2 |
---|---|
100 | 1 |
100 | 2 |
200 | 1 |
200 | 2 |
200 | 3 |
200 | 2 |
300 | 1 |
300 | 2 |
300 | 3 |
300 | 4 |
Basically, for every value in "Field1"
a unique value should be in "Field2"
: 100.1, 100.2, etc. it's ok, to have two 200.2 it's not.
I'm using these PyQGIS lines to find duplicates within the same field:
import collections
layer = iface.activeLayer()
list_of_values = QgsVectorLayerUtils.getValues(layer, 'Field1')[0]
list_of_values.sort()
print([item for item, count in collections.Counter(list_of_values).items() if count > 1])
but I can't modify them in the proper way to achieve these results.