home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 423023519

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
423023519 MDU6SXNzdWU0MjMwMjM1MTk= 2825 KeyError on selecting empty time slice from a datetime-indexed Dataset 2418513 open 0     4 2019-03-20T01:21:56Z 2019-03-20T17:58:24Z   NONE      

(xarray version: 0.11.3)

Just wanted to confirm this is expected behaviour: sel() with a date that would yield an empty selection throws an exception (I would naturally expect it to return a zero-length dataarray/dataset instead):

```python

foo = xr.DataArray( np.array([1, 2, 3]), {'t': pd.to_datetime(['2018-01-01', '2018-02-02T01:01', '2018-02-02T02:02'])}, dims=['t'] )

foo.sel(t='2018-01-01').size 1

foo.sel(t='2018-02-02').size 2

foo.sel(t='2018-03-03').size # expected 0?

pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() TypeError: an integer is required

During handling of the above exception, another exception occurred:

pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine._date_check_type() KeyError: '2018-03-03'

During handling of the above exception, another exception occurred:

pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() TypeError: an integer is required

During handling of the above exception, another exception occurred:

pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine._date_check_type()

KeyError: '2018-03-03'

During handling of the above exception, another exception occurred:

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() KeyError: 1520035200000000000

During handling of the above exception, another exception occurred:

pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() KeyError: Timestamp('2018-03-03 00:00:00')

During handling of the above exception, another exception occurred:

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item() KeyError: 1520035200000000000

During handling of the above exception, another exception occurred:

pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc() KeyError: Timestamp('2018-03-03 00:00:00')

...

```

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

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 0.572ms · About: xarray-datasette