# Is there a function similar to numpy unique with inverse?

**URL:** <https://discourse.julialang.org/t/is-there-a-function-similar-to-numpy-unique-with-inverse/80949>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 12, 2022, 11:01am UTC](https://discourse.julialang.org/t/is-there-a-function-similar-to-numpy-unique-with-inverse/80949 "2022-05-12T11:01:56Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 12, 2022, 12:11pm UTC](https://discourse.julialang.org/t/is-there-a-function-similar-to-numpy-unique-with-inverse/80949/6 "2022-05-12T12:11:16Z")

</div>

See also:

- [Unique (indices) method similar to MATLAB](https://discourse.julialang.org/t/unique-indices-method-similar-to-matlab/34446)
- [indices of unique elements of vector in Julia - Stack Overflow](https://stackoverflow.com/questions/50899973/indices-of-unique-elements-of-vector-in-julia)
- [https://groups.google.com/g/julia-users/c/205gVuPuZFU?pli=1](https://groups.google.com/g/julia-users/c/205gVuPuZFU?pli=1)
- [https://github.com/JuliaLang/julia/issues/1845](https://github.com/JuliaLang/julia/issues/1845)

And in particular [this solution](https://discourse.julialang.org/t/unique-indices-method-similar-to-matlab/34446/3):

```julia
uniqueinds(x) = unique(i -> x[i], eachindex(x))

```

However, this isn’t quite the same thing: it’s equivalent to [`return_index=True` in `numpy.unique`](https://numpy.org/doc/stable/reference/generated/numpy.unique.html), not `return_inverse=True`.

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-function-similar-to-numpy-unique-with-inverse/80949)._
