home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

10 rows where issue = 1391699976 sorted by updated_at descending

✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: reactions, created_at (date), updated_at (date)

user 4

  • benbovy 3
  • max-sixty 3
  • AlxLhrNc 3
  • rhkleijn 1

author_association 3

  • MEMBER 6
  • NONE 3
  • CONTRIBUTOR 1

issue 1

  • .sel return errors when using floats for no apparent reason · 10 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1267830185 https://github.com/pydata/xarray/issues/7108#issuecomment-1267830185 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85LkY2p AlxLhrNc 90059220 2022-10-05T02:21:15Z 2022-10-05T02:21:15Z NONE

Thanks, it finally worked.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976
1266073388 https://github.com/pydata/xarray/issues/7108#issuecomment-1266073388 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85Ldr8s benbovy 4160723 2022-10-03T21:28:43Z 2022-10-03T21:28:43Z MEMBER

I suppose re-projecting it on a 0-360 would be the only way around this specific issue.

A custom Xarray index would help, e.g., PeriodicBoundaryIndex (#7031) or a GeographicIndex leveraging libraries like S2Geometry or H3.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976
1266030505 https://github.com/pydata/xarray/issues/7108#issuecomment-1266030505 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85Ldhep AlxLhrNc 90059220 2022-10-03T20:49:24Z 2022-10-03T20:49:24Z NONE

The values in nc.lon are technically ordered 'as they would be on a mercator projected map with origin at 0 N-0 E' considering I am dealing with data around 180 lon. Not that it would mater for pandas/xarray in that case. I suppose re-projecting it on a 0-360 would be the only way around this specific issue.

And to answer earlier comments, sub = nc_bug.sel(lon = 161.001, tolerance=.1) raised the following: KeyError: "not all values found in index 'lon'. Try setting themethodkeyword argument (example: method='nearest')." Which, when tried raised ValueError: index must be monotonic increasing or decreasing. It is indeed a problem with the order of the index.

Thanks for your help and your time.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976
1265012286 https://github.com/pydata/xarray/issues/7108#issuecomment-1265012286 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85LZo4- benbovy 4160723 2022-10-03T06:57:17Z 2022-10-03T06:57:17Z MEMBER

TBH, I had to do some research before figuring out what was going on :).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976
1263807395 https://github.com/pydata/xarray/issues/7108#issuecomment-1263807395 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85LVCuj max-sixty 5635139 2022-09-30T16:59:06Z 2022-09-30T16:59:06Z MEMBER

Float indexes are often a source of pain, unfortunately!

...also for my ability to know what's going on, apparently :). Thanks a lot @benbovy .


Yes, that would be great to raise a more informative error. We could also put an issue in upstream if pandas itself has the same issue.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976
1263689036 https://github.com/pydata/xarray/issues/7108#issuecomment-1263689036 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85LUl1M rhkleijn 32801740 2022-09-30T15:01:42Z 2022-09-30T15:01:42Z CONTRIBUTOR

Pandas docs seem stricter than the implementation. From this snippet from pandas source code monotonicity is only required after get_loc fails.

My concern with checking first is that code like below will stop working (if I understand correctly). Is has unique but (alphabetically) unsorted coords (although its order may have meaning for the user). I regularly select a slice by specifying the labels corresponding to the first and last elements I want to extract.

I would suggest in this case to just try while catching any KeyError and raising with a nicer message instead of always checking first.

import xarray as xr da = xr.DataArray([0, 1, 2, 3], coords={'x': ['zero', 'one', 'two', 'three']}) da.sel(x=slice('zero', 'two')) Out[1]: <xarray.DataArray (x: 3)> array([0, 1, 2]) Coordinates: * x (x) <U5 'zero' 'one' 'two'

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976
1263548977 https://github.com/pydata/xarray/issues/7108#issuecomment-1263548977 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85LUDox benbovy 4160723 2022-09-30T13:03:26Z 2022-09-30T13:03:26Z MEMBER

It looks like the error is because of the non-monotonic coordinate labels for the "lon" coordinate in nc_bug rather than a float precision issue. The "lon" coordinate seems monotonic for nc_ok so it works.

When a slice is given as indexer, Xarray internally calls pandas.Index.slice_indexer(), which requires that the index must be ordered and unique (docs). Unfortunately, Pandas does not mention it while it raises a KeyError. Should we first check the index in Xarray and raise a nicer error message if it is not unique / ordered?

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976
1263070017 https://github.com/pydata/xarray/issues/7108#issuecomment-1263070017 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85LSOtB max-sixty 5635139 2022-09-30T03:49:51Z 2022-09-30T03:49:51Z MEMBER

Ah, right. Does it select a value with just nc_bug.sel(lon = 161.001, tolerance=0.1)? Because the lon value which that selects is probably the value you need to use in the slice.

Float indexes are often a source of pain, unfortunately!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976
1263045823 https://github.com/pydata/xarray/issues/7108#issuecomment-1263045823 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85LSIy_ AlxLhrNc 90059220 2022-09-30T02:58:34Z 2022-09-30T02:58:34Z NONE

Returned the following: NotImplementedError: cannot use ``method`` argument if any indexers are slice objects

``` Traceback (most recent call last):

Cell In [3], line 1 sub = nc_bug.sel(lon = slice(161.001, 162.001), tolerance=0.1)

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\xarray\core\dataset.py:2533 in sel query_results = map_index_queries(

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\xarray\core\indexing.py:183 in map_index_queries results.append(index.sel(labels, **options)) # type: ignore[call-arg]

File ~\Installed_Programs\Anaconda3\envs\phd\lib\site-packages\xarray\core\indexes.py:377 in sel indexer = _query_slice(self.index, label, coord_name, method, tolerance) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976
1263040310 https://github.com/pydata/xarray/issues/7108#issuecomment-1263040310 https://api.github.com/repos/pydata/xarray/issues/7108 IC_kwDOAMm_X85LSHc2 max-sixty 5635139 2022-09-30T02:47:13Z 2022-09-30T02:47:13Z MEMBER

Generally this is because the floats aren't exactly the same value — does passing tolerance=0.1 help?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  .sel return errors when using floats for no apparent reason 1391699976

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 964.124ms · About: xarray-datasette
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows