home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 276537615

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/60#issuecomment-276537615 https://api.github.com/repos/pydata/xarray/issues/60 276537615 MDEyOklzc3VlQ29tbWVudDI3NjUzNzYxNQ== 8982598 2017-02-01T00:26:24Z 2017-02-01T00:26:24Z CONTRIBUTOR

Ah yes both ways are working now, thanks. Just had a little play around with timings, and this seems like a reasonably quick way to achieve correct NaN behaviour:

```python def xr_idxmax(obj, dim): sig = ([(dim,), (dim,)], [()]) kwargs = {'axis': -1}

allna = obj.isnull().all(dim)

return apply_ufunc(gufunc_idxmax, obj.fillna(-np.inf), obj[dim],
                   signature=sig, kwargs=kwargs,
                   dask_array='allowed').where(~allna).fillna(np.nan)

```

i.e. originally replace all NaN values with -Inf, use the usual argmax, and remask the all-NaN values afterwards.

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