home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1195659402

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1195659402 I_kwDOAMm_X85HRFCK 6450 workaround to implement groupby_bins along dimension 45175997 closed 0     1 2022-04-07T07:56:35Z 2022-04-15T01:38:49Z 2022-04-15T01:38:49Z CONTRIBUTOR      

What is your issue?

There are several related issues dealing with groupby operations along individual/multiple dimensions (e.g. #1056 #924 ). I understand that this is work in progress. In the meantime, however, I'm looking for a quick solution to group over bins along a single dimension. Grouping over all dimensions works, e.g.:

```py

da = xr.DataArray(np.random.randint(9, size=(5, 2, 3)), dims=['time', 'x', 'y']) da

xarray.DataArraytime: 5x: 2y: 3 array([[[1, 1, 5], [5, 6, 0]],

   [[3, 2, 4],
    [2, 8, 4]],

   [[0, 0, 2],
    [6, 3, 5]],

   [[4, 6, 4],
    [8, 2, 4]],

   [[6, 5, 3],
    [5, 2, 6]]])

Coordinates: (0) Attributes: (0)

da.groupby_bins(da, bins=[0, 5, 10]).count()

xarray.DataArray 'group' group_bins: 2 array([20, 7]) Coordinates: (1) Attributes: (0) ```

However, it fails when trying to apply the operator only along a specific dimension, e.g.: ```py

da.groupby_bins(da, bins=[0, 5, 10]).count('time')

ValueError: cannot reduce over dimensions ['time']. expected either '...' to reduce over all dimensions or one or more of ('stacked_time_x_y',). ``` I don't mind if the workaround is a bit ugly as long as it works ;)

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6450/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 158.205ms · About: xarray-datasette