home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 364293763

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/1847#issuecomment-364293763 https://api.github.com/repos/pydata/xarray/issues/1847 364293763 MDEyOklzc3VlQ29tbWVudDM2NDI5Mzc2Mw== 6815844 2018-02-09T00:18:52Z 2018-02-09T00:19:33Z MEMBER

It looks that our where does not do type-casting (inheriting from numpy's where), ```python In [1]: import numpy as np ...: import xarray as xr ...: a = xr.Variable('x', np.array(['a', 'b', 'c']))

In [2]: a._getitem_with_mask([1, 2, -1]) Out[2]: <xarray.Variable (x: 3)> array(['b', 'c', 'nan'], dtype='<U32') ``` nan is converted to string.

I guess we need to cast arrays manually in _getitem_with_mask before where is applied. python In [9]: dtype, fill_value = xr.core.dtypes.maybe_promote(a.dtype) ...: a.astype(dtype)._getitem_with_mask([1, 2, -1]) Out[9]: <xarray.Variable (x: 3)> array(['b', 'c', nan], dtype=object)

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