issues: 594900245
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
594900245 | MDU6SXNzdWU1OTQ5MDAyNDU= | 3941 | Sum based on start_index and end_index array | 30388627 | closed | 0 | 5 | 2020-04-06T08:15:57Z | 2020-04-07T02:45:26Z | 2020-04-07T02:45:26Z | NONE | I have three arrays:
1. MCVE Code Sample```python import xarray as xr data = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) input arraya = xr.DataArray(data, dims=['x', 'y']) start_index arraysindex = xr.DataArray(np.array([0, 0, 1, 1]), dims=['x']) end_index arrayeindex = xr.DataArray(np.array([0, 1, 2, 2]), dims=['x']) empty array for saving summationsum_a = xr.DataArray(np.empty((a.shape[0], 1)), dims=['x', 'y']) for x in a.x: # sum values from sindex to eindex at row x sum_a[x] = a[x, sindex[x].values:eindex[x].values+1].sum() print(sum_a) ``` Expected Output
Problem DescriptionIs it necessary to use |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/3941/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |