# How to replace multiple values in an large array with the occurrence of the value?

**URL:** https://discourse.julialang.org/t/how-to-replace-multiple-values-in-an-large-array-with-the-occurrence-of-the-value/50741
**Category:** General Usage
**Tags:** question, array
**Created:** [November 25, 2020, 10:55am UTC](https://discourse.julialang.org/t/how-to-replace-multiple-values-in-an-large-array-with-the-occurrence-of-the-value/50741 "2020-11-25T10:55:03Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [November 27, 2020, 8:24am UTC](https://discourse.julialang.org/t/how-to-replace-multiple-values-in-an-large-array-with-the-occurrence-of-the-value/50741/8 "2020-11-27T08:24:04Z")

</div>

@JeffreySarnoff, thanks for your time and answer, but it issues error messages:

```julia
function elcount6!(blobs, blobs_occ)
    @inbounds for j in axes(blobs,2), i in axes(blobs,1)
        blobs[i,j] = blobs_occ[blobs[i,j]];
    end
    return blobs
end

blobs = rand(0:9,10_000,10_000);
blobs_occ = countmap(vec(blobs))
@btime elcount6!($blobs, $blobs_occ)

julia> @btime elcount6!($blobs, $blobs_occ)
ERROR: KeyError: key 10002175 not found
Stacktrace:
 [1] getindex at .\dict.jl:467 [inlined]
 ...

```

Some [setup](https://discourse.julialang.org/t/how-to-benchmark-in-place-functions/36493) seems to be required to `@btime` in-place modifying functions but I did not figure out yet how to do it for the function above.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-replace-multiple-values-in-an-large-array-with-the-occurrence-of-the-value/50741)._
