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/3941#issuecomment-609882875,https://api.github.com/repos/pydata/xarray/issues/3941,609882875,MDEyOklzc3VlQ29tbWVudDYwOTg4Mjg3NQ==,2448579,2020-04-06T15:59:37Z,2020-04-06T15:59:37Z,MEMBER,why not?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,594900245
https://github.com/pydata/xarray/issues/3941#issuecomment-609827384,https://api.github.com/repos/pydata/xarray/issues/3941,609827384,MDEyOklzc3VlQ29tbWVudDYwOTgyNzM4NA==,2448579,2020-04-06T14:24:53Z,2020-04-06T14:24:53Z,MEMBER,"`where` is usually the solution for this kind of problem. I added the `keepdims` to keep the `y` dimension after the sum.
``` python
yindex = a.y.copy(data=np.arange(a.sizes[""y""])) # generate DataArray of indexes
a.where((yindex >= sindex) & (yindex <= eindex)).sum(""y"", keepdims=True)
```
Please close if this answers your question.","{""total_count"": 4, ""+1"": 4, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,594900245