home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 422076318

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/1613#issuecomment-422076318 https://api.github.com/repos/pydata/xarray/issues/1613 422076318 MDEyOklzc3VlQ29tbWVudDQyMjA3NjMxOA== 1217238 2018-09-17T16:09:54Z 2018-09-17T16:09:54Z MEMBER

Consider using index.is_monotonic_ascending and index.is_monotonic_descending instead of subtracting the first few values -- those are exactly the checks that pandas uses.

I also did a little more searching and found that this has come up in the xarray issue tracker before: https://github.com/pydata/xarray/issues/1465


Thinking about this a little more, I'm remembering the reasoning for pandas working this way:

  1. Integer slicing by position and by label with positive integers should work the same for an index with values given by range(N).
  2. Positional indexing in Python x[a:b] returns all values between a and b in order. Indexing like x[high:low] with high > low returns an empty list.
  3. Label based indexing in pandas has df.loc[df.index[i] : df.index[j]] equivalent to df.iloc[i : j+1] (arguably this is a mistake; e.g., https://github.com/pydata/xarray/issues/1492 and other discussion that I can't find right now :) ).
  4. Indexing a monotonic decreasing index therefore should work for decreasing labels.
  5. If slicing a monotonic increasing index only works for increasing but not decreasing labels, then it would be weird if indexing a monotonic decreasing index works for both increasing and decreasing labels.
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  263403430
Powered by Datasette · Queries took 0.882ms · About: xarray-datasette