Skip to content

Instantly share code, notes, and snippets.

@huangziwei
Created October 23, 2017 13:10
Show Gist options
  • Save huangziwei/444db745a8eaa71fd34b81d5398d95b4 to your computer and use it in GitHub Desktop.
Save huangziwei/444db745a8eaa71fd34b81d5398d95b4 to your computer and use it in GitHub Desktop.
find unique_row in numpy.array
def unique_row(a):
b = np.ascontiguousarray(a).view(np.dtype((np.void, a.dtype.itemsize * a.shape[1])))
_, idx = np.unique(b, return_index=True)
unique_a = a[idx]
return unique_a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment