Created
October 23, 2017 13:10
-
-
Save huangziwei/444db745a8eaa71fd34b81d5398d95b4 to your computer and use it in GitHub Desktop.
find unique_row in numpy.array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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