With np.unique from v1.13 (downloaded from source link in latest documentation, https://github.com/numpy/numpy/blob/master/numpy/lib/arraysetops.py#L112-L247 )
In [157]: aset.unique(test_rows, axis=0,return_inverse=True,return_index=True) Out[157]: (array([[0, 0, 0], [0, 1, 0], [0, 1, 1], [1, 1, 0], [1, 1, 1]]), array([2, 1, 0, 3, 7], dtype=int32), array([2, 1, 0, 3, 1, 2, 2, 4, 3, 4, 1, 0, 3], dtype=int32)) In [158]: a,b,c=_ In [159]: c Out[159]: array([2, 1, 0, 3, 1, 2, 2, 4, 3, 4, 1, 0, 3], dtype=int32) In [164]: from collections import defaultdict In [165]: dd = defaultdict(list) In [166]: for i,v in enumerate(c): ...: dd[v].append(i) ...: In [167]: dd Out[167]: defaultdict(list, {0: [2, 11], 1: [1, 4, 10], 2: [0, 5, 6], 3: [3, 8, 12], 4: [7, 9]})
or indexing a dictionary with unique lines (like a hashed tuple):
In [170]: dd = defaultdict(list) In [171]: for i,v in enumerate(c): ...: dd[tuple(a[v])].append(i) ...: In [172]: dd Out[172]: defaultdict(list, {(0, 0, 0): [2, 11], (0, 1, 0): [1, 4, 10], (0, 1, 1): [0, 5, 6], (1, 1, 0): [3, 8, 12], (1, 1, 1): [7, 9]})