home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 268355105

This data as json

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/pull/964#issuecomment-268355105 https://api.github.com/repos/pydata/xarray/issues/964 268355105 MDEyOklzc3VlQ29tbWVudDI2ODM1NTEwNQ== 5635139 2016-12-20T20:46:55Z 2016-12-20T20:46:55Z MEMBER

Gave this a quick spin for filling. A few questions:

  • Is there an easy of way of merely translating dims into axes? Maybe that already exists?
  • Is there as easy way to keep a dimension? Or should it be in the signature and a new_dim?

```python da=xr.DataArray(np.random.rand(10,3), dims=('x','y')) da = da.where(da>0.5) In [43]: da Out[43]: <xarray.DataArray (x: 10, y: 3)> array([[ nan, 0.57243305, 0.84363016], [ nan, 0.90788156, nan], [ nan, 0.50739189, 0.93701278], [ nan, nan, 0.86804167], [ nan, 0.50883914, nan], [ nan, nan, nan], [ nan, 0.91547763, nan], [ 0.72920182, nan, 0.6982745 ], [ 0.73033449, 0.950719 , 0.73077113], [ nan, nan, 0.72463932]])

In [44]: xr.apply(bn.push, da) . # already better than bn.push(da)! Out[44]: <xarray.DataArray (x: 10, y: 3)> array([[ nan, 0.57243305, 0.84363016], [ nan, 0.90788156, 0.90788156], [ nan, 0.50739189, 0.93701278], [ nan, nan, 0.86804167], [ nan, 0.50883914, 0.50883914], [ nan, nan, nan], [ nan, 0.91547763, 0.91547763], [ 0.72920182, 0.72920182, 0.6982745 ], [ 0.73033449, 0.950719 , 0.73077113], [ nan, nan, 0.72463932]])

but changing the axis is verbose and transposes the array - are there existing tools for this?

In [48]: xr.apply(bn.push, da, signature='(x)->(x)', new_coords=[dict(x=da.x)]) Out[48]: <xarray.DataArray (y: 3, x: 10)> array([[ nan, nan, nan, nan, nan, nan, nan, 0.72920182, 0.73033449, 0.73033449], [ 0.57243305, 0.90788156, 0.50739189, 0.50739189, 0.50883914, 0.50883914, 0.91547763, 0.91547763, 0.950719 , 0.950719 ], [ 0.84363016, 0.84363016, 0.93701278, 0.86804167, 0.86804167, 0.86804167, 0.86804167, 0.6982745 , 0.73077113, 0.72463932]]) Coordinates: * x (x) int64 0 1 2 3 4 5 6 7 8 9 o y (y) - ```

  • The triple nested signature is pretty tough to write! Two kwargs?
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  170779798
Powered by Datasette · Queries took 80.91ms · About: xarray-datasette