home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 499285779

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/issues/2834#issuecomment-499285779 https://api.github.com/repos/pydata/xarray/issues/2834 499285779 MDEyOklzc3VlQ29tbWVudDQ5OTI4NTc3OQ== 3621629 2019-06-05T22:56:00Z 2019-06-05T22:58:18Z CONTRIBUTOR

Hello @maxdow

I'm not sure I understand your issue correctly. If all you want is to keep only the points time, lat, lon for which t and/or dd is not NA you can simply use ```python z = d.stack(index=d.dims).dropna('index', how='all')

<xarray.Dataset> Dimensions: (index: 346) Coordinates: * index (index) MultiIndex - time (index) datetime64[ns] 2019-03-09 2019-03-09 ... 2019-03-09 - lat (index) float64 43.5 43.5 43.5 43.75 43.75 ... 45.0 45.0 45.5 45.5 - lon (index) float64 1.25 1.5 4.25 1.75 2.25 ... 1.75 2.0 4.0 1.5 2.0 Data variables: t (index) float64 0.6184 0.2966 1.426 0.8666 ... 0.09348 1.271 1.353 dd (index) float64 2.075 1.174 0.906 0.6451 ... 0.3491 0.1789 0.8922 You still have access to the coordinates of the valid points through `z.time`, `z.lat` and `z.lon`:python z.lat

<xarray.DataArray 'lat' (index: 346)> array([43.5 , 43.5 , 43.5 , ..., 51.25, 51.25, 51.25]) Coordinates: * index (index) MultiIndex - time (index) datetime64[ns] 2019-03-09 2019-03-09 ... 2019-03-09 - lat (index) float64 43.5 43.5 43.5 43.75 43.75 ... 45.0 45.0 45.5 45.5 - lon (index) float64 1.25 1.5 4.25 1.75 2.25 ... 1.75 2.0 4.0 1.5 2.0 ```

One can still unstack this and achieve the equivalent of multi-dimensional dropna. However in your example all the coordinates for time look equal (they shouldn't be) and this will prevent unstacking.

I hope this helps

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  423632904
Powered by Datasette · Queries took 0.495ms · About: xarray-datasette