html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/6758#issuecomment-1176918900,https://api.github.com/repos/pydata/xarray/issues/6758,1176918900,IC_kwDOAMm_X85GJlt0,2448579,2022-07-07T01:03:17Z,2022-07-07T01:03:17Z,MEMBER,"> the IDL histogram function but in numpy. Apparently [not](https://github.com/numpy/numpy/issues/9032) as [awesome!](http://www.idlcoyote.com/tips/histogram_tutorial.html)","{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1295939038 https://github.com/pydata/xarray/issues/6758#issuecomment-1176730713,https://api.github.com/repos/pydata/xarray/issues/6758,1176730713,IC_kwDOAMm_X85GI3xZ,2448579,2022-07-06T20:54:23Z,2022-07-06T20:54:23Z,MEMBER,"Yes that's right. For this simple problem you could combine `np.digitize` and `np.bincount` to do it much quicker. ``` python group_idx = np.digitize(latitude, bins) sums = np.bincount(group_idx, weights=array) ``` And then wrap this using apply_ufunc. See https://github.com/ml31415/numpy-groupies/blob/412be938dcdfd74c6d673dd29012d18dc25dc94f/numpy_groupies/aggregate_numpy.py#L8-L28 for inspiration.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1295939038 https://github.com/pydata/xarray/issues/6758#issuecomment-1176441916,https://api.github.com/repos/pydata/xarray/issues/6758,1176441916,IC_kwDOAMm_X85GHxQ8,2448579,2022-07-06T16:40:47Z,2022-07-06T16:40:47Z,MEMBER,"On xarray main with [flox](https://flox.readthedocs.io) installed: ``` python import numpy as np import xarray as xr display(xr.__version__) N = 3728 ds = xr.Dataset() ds[""latitude""] = (""x"", 0 + 20 * np.random.standard_normal(N)) ds[""data""] = (""x"", 0 + 100 * np.random.standard_normal(N)) %timeit ds.groupby_bins(""latitude"", np.arange(-40, 40, 0.1)).sum() ``` 50.3 ms ± 203 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) You could try it on our pre-release (https://docs.xarray.dev/en/latest/whats-new.html#v2022-06-0rc0-9-june-2022) or use xhistogram which should be faster even.","{""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 1, ""rocket"": 0, ""eyes"": 0}",,1295939038