home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 1086751973

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/6434#issuecomment-1086751973 https://api.github.com/repos/pydata/xarray/issues/6434 1086751973 IC_kwDOAMm_X85AxoTl 2448579 2022-04-03T01:00:48Z 2022-04-03T02:02:34Z MEMBER

which doesn't seem to create the right kind of index given the value type:

There's a typo in the first line, we need da.time, this does actually work ``` array = da.isel(time=0).time.values value = array.item() seq = np.array([value], dtype=array.dtype) pd.Index(seq, dtype=array.dtype)

DatetimeIndex(['2013-01-01'], dtype='datetime64[ns]', freq=None)

```

The issue is that the .item() converts datetime64 to int and so safe_cast_to_index creates a IntIndex because we don't pass dtype to the pd.Index constructor (so that's one possible fix): https://github.com/pydata/xarray/blob/3ead17ea9e99283e2511b65b9d864d1c7b10b3c4/xarray/core/utils.py#L130-L133

Alternatively, we could loop over datasets and call expand_dims if dim is present and is a scalar. We already do something similar here: https://github.com/pydata/xarray/blob/305533d585389f7240ae2383a323337d4761d33a/xarray/core/concat.py#L470-L472

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