# Equivalent of numpy.repeat

**URL:** <https://discourse.julialang.org/t/equivalent-of-numpy-repeat/73359>\
**Category:** New to Julia\
**Created:** [December 20, 2021, 8:42am UTC](https://discourse.julialang.org/t/equivalent-of-numpy-repeat/73359 "2021-12-20T08:42:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CompulsoryCoffee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compulsorycoffee/32/30434_2.png) [@CompulsoryCoffee](https://discourse.julialang.org/u/CompulsoryCoffee)\
**Post date:** [December 20, 2021, 8:42am UTC](https://discourse.julialang.org/t/equivalent-of-numpy-repeat/73359/1 "2021-12-20T08:42:15Z")

</div>

Hi,  
I found some comments on the matter online but nothing that would repeat elekemtn of a list based on a count given by a list like:

```julia
import numpy as np

x = np.array([1, 2])
print np.repeat(x, [2, 3], axis=0)

```

I would like a results to be like

```julia
[1, 1, 2, 2, 2]

```

I tried the repeat function but it doesn’t seem to work.

Thanks

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [December 20, 2021, 8:49am UTC](https://discourse.julialang.org/t/equivalent-of-numpy-repeat/73359/2 "2021-12-20T08:49:47Z")

</div>

See here:

[https://stackoverflow.com/questions/69990035/julia-repeat-entries-of-a-vector-by-another-vector-inner](https://stackoverflow.com/questions/69990035/julia-repeat-entries-of-a-vector-by-another-vector-inner)

---

<div class="post-metadata">

**Author:** ![CompulsoryCoffee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compulsorycoffee/32/30434_2.png) [@CompulsoryCoffee](https://discourse.julialang.org/u/CompulsoryCoffee)\
**Post date:** [December 20, 2021, 8:51am UTC](https://discourse.julialang.org/t/equivalent-of-numpy-repeat/73359/3 "2021-12-20T08:51:57Z")

</div>

Great - exactly what I needed!
