# Iterators over observations/data

**URL:** <https://discourse.julialang.org/t/iterators-over-observations-data/65158>\
**Category:** Performance\
**Tags:** package\
**Created:** [July 23, 2021, 9:35am UTC](https://discourse.julialang.org/t/iterators-over-observations-data/65158 "2021-07-23T09:35:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephancb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephancb/32/14243_2.png) [@stephancb](https://discourse.julialang.org/u/stephancb)\
**Post date:** [July 23, 2021, 9:35am UTC](https://discourse.julialang.org/t/iterators-over-observations-data/65158/1 "2021-07-23T09:35:11Z")

</div>

Is there a reason why in StatsBase `fit(Histogram, obs::AbstractArray, bins,...)` does not accept an iterator over the observations? Possible sources of observations are streams, csv files, databases etc. To just bin them indexing, `getindex(obs, ...)`, is not needed? In my case a 2d histogram is made from ~250 MB of observations in an SQLite database, so this is presently not a show stopper. Typical data sets for histograms fit easily into arrays in memory, but it is not always the case.

I have tried to look at the binning part in the code, but it is a bit over my horizon. Are there alternative packages? In MATLAB `accumarray` can do the job, vectorized. It is adapted to Julia in [VectorizedRoutines](https://github.com/ChrisRackauckas/VectorizedRoutines.jl)

Generally an iterator interface to data would avoid allocations and be more “Julian”.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [July 23, 2021, 3:39pm UTC](https://discourse.julialang.org/t/iterators-over-observations-data/65158/2 "2021-07-23T15:39:32Z")

</div>

> [@stephancb](#):
>
> Are there alternative packages?

OnlineStats.jl was made for exactly this kind of streaming statistics.
