home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 596352097

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
596352097 MDU6SXNzdWU1OTYzNTIwOTc= 3955 Masking and preserving int type 30388627 closed 0     5 2020-04-08T06:56:26Z 2022-05-02T19:25:42Z 2022-05-02T19:25:42Z NONE      

When DataArray is masked by .where(), the type is converted to float64.

But, if we need to use the DataArray ouput from .where() in .isel(), the dtype should be int. (#3949 )

MCVE Code Sample

```python import numpy as np import xarray as xr

val_arr = xr.DataArray(np.arange(27).reshape(3, 3, 3), dims=['z', 'y', 'x'])

z_indices = xr.DataArray(np.array([[1, 0, 2], [0, 0, 1], [-2222, 0, 1]]), dims=['y', 'x'])

fill_value = -2222 sub = z_indices.where(z_indices != fill_value) indexed_array = val_arr.isel(z=sub) ```

Expected Output

array([[ 1, 0, 2], [ 0, 0, 1], [nan, 0, 1]])

Problem Description

File "E:\miniconda3\envs\satpy\lib\site-packages\xarray\core\indexing.py", line 446, in __init__ f"invalid indexer array, does not have integer dtype: {k!r}" TypeError: invalid indexer array, does not have integer dtype: array([[ 1., 0., 2.], [ 0., 0., 1.], [nan, 0., 1.]])

Currently, pandas supports NaN values. Is this possible for xarray? or another method around?

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3955/reactions",
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 1,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 5 rows from issue in issue_comments
Powered by Datasette · Queries took 0.619ms · About: xarray-datasette