[Numpy-discussion] Adding an axis argument to numpy.unique
Sun Aug 18 18:14:55 CDT 2013
I've recently put together a pull request that adds an `axis` kwarg to
`numpy.unique` so that `unique`can easily be used to find unique
rows/columns/sub-arrays/etc of a larger array.
Currently, this works as a warpper around `unique`. If `axis` is specified,
it reshapes the input to a 2D contiguous array, views each row as a single
item, then passes it on to `unique`. For int and string dtypes, each row
is viewed as a void dtype and therefore bitwise-equality is used for
comparisons. For all other dtypes, the each row is viewed as a structured
The current implementation has two main drawbacks:
1. For anything other than ints and strings, it's relatively slow.
2. It doesn't work with object arrays of any sort.
I'd appreciate any thoughts/feedback folks might have on both the general
idea and this specific implementation. It think it's a worthwhile
addition, but I'm biased.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion