home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

11 rows where issue = 383945783 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 6

  • ahuang11 4
  • shoyer 3
  • dcherian 1
  • max-sixty 1
  • ewineteer 1
  • stale[bot] 1

author_association 3

  • MEMBER 5
  • CONTRIBUTOR 4
  • NONE 2

issue 1

  • Xarray equivalent of np.place or df.map(mapping)? · 11 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1101516537 https://github.com/pydata/xarray/issues/2568#issuecomment-1101516537 https://api.github.com/repos/pydata/xarray/issues/2568 IC_kwDOAMm_X85Bp875 dcherian 2448579 2022-04-18T15:51:57Z 2022-04-18T15:51:57Z MEMBER

There's a longer discussion in #6377 so let's close this.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
1100903860 https://github.com/pydata/xarray/issues/2568#issuecomment-1100903860 https://api.github.com/repos/pydata/xarray/issues/2568 IC_kwDOAMm_X85BnnW0 stale[bot] 26384082 2022-04-17T15:43:46Z 2022-04-17T15:43:46Z NONE

In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity

If this issue remains relevant, please comment here or remove the stale label; otherwise it will be marked as closed automatically

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
671101989 https://github.com/pydata/xarray/issues/2568#issuecomment-671101989 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDY3MTEwMTk4OQ== ahuang11 15331990 2020-08-09T21:15:41Z 2020-08-09T21:15:41Z CONTRIBUTOR

If I were to make a PR, where would this method reside? Would it be under dataset.py and dataarray.py? Also, would I simply call np.select inside the method, and if so, how would I add support for dask?

My minimal example atm: ``` import xarray as xr import numpy as np import hvplot.xarray

ds = xr.tutorial.open_dataset('air_temperature').isel(time=0)

ds['air_cats'] = ( ('lat', 'lon'), np.select([ds['air'].values >= 273.15, ds['air'].values < 273.15], ['above freezing', 'below freezing']) ) ds.hvplot('lon', 'lat', hover_cols=['air_cats']) ```

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
599133152 https://github.com/pydata/xarray/issues/2568#issuecomment-599133152 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDU5OTEzMzE1Mg== ahuang11 15331990 2020-03-14T20:48:52Z 2020-03-14T20:48:52Z CONTRIBUTOR

No, not from me at least.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
599131699 https://github.com/pydata/xarray/issues/2568#issuecomment-599131699 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDU5OTEzMTY5OQ== ewineteer 26352311 2020-03-14T20:33:19Z 2020-03-14T20:33:19Z NONE

Has any progress been made on adding a builtin function for this? Thanks.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
441483832 https://github.com/pydata/xarray/issues/2568#issuecomment-441483832 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDQ0MTQ4MzgzMg== max-sixty 5635139 2018-11-25T23:30:36Z 2018-11-25T23:30:36Z MEMBER

Agree that map is not a good name (and I find the pandas API difficult in this area - each time I'm looking up what relabel / rename / map / select / filter does)

How about match / switch / case?

We would definitely use this. I agree it'd probably be used less in xarray than in pandas; though I'm keen to expand the API, in a deliberate and careful way, to some of the traditional pandas use-cases (but a small vote among many)

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
441467391 https://github.com/pydata/xarray/issues/2568#issuecomment-441467391 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDQ0MTQ2NzM5MQ== shoyer 1217238 2018-11-25T19:50:16Z 2018-11-25T19:50:16Z MEMBER

I would lean slightly against adding a dedicated method for this (but could be convinced if others are interested). Usually we copy pandas or numpy APIs, but DataFrame.map is a not a great name -- map means too many other things (e.g., consider the buildin map).

It might make sense to copy the design of numpy.select instead: https://docs.scipy.org/doc/numpy/reference/generated/numpy.select.html

e.g., you could write something like xarray.select([ds < 0, ds < 10], [5, 10], default=15)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
441344567 https://github.com/pydata/xarray/issues/2568#issuecomment-441344567 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDQ0MTM0NDU2Nw== ahuang11 15331990 2018-11-24T05:17:09Z 2018-11-24T05:25:45Z CONTRIBUTOR

Thanks for the quick replies! Is there interest in making this a built-in function? If so, I can help contribute a PR.

Also wondering about a way to wrap logic to that mapping.

Like below 0, replace with -1, between 0 and 10, replace with 5, and above 10, replace with 15 which is possible with three np.place statements I think, but have to think in backwards logic with ds.where().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
441343812 https://github.com/pydata/xarray/issues/2568#issuecomment-441343812 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDQ0MTM0MzgxMg== shoyer 1217238 2018-11-24T04:56:21Z 2018-11-24T04:56:33Z MEMBER

I would divide this into two steps: (1) write a function that does this on NumPy arrays and (2) apply it to xarray objects using apply_ufunc, e.g.,

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

def remap(array, mapping): return np.array([mapping[k] for k in array.ravel()]).reshape(array.shape)

ds = xr.Dataset({'test': ('t', [0, 1, 2])}) xr.apply_ufunc(remap, ds, kwargs=dict(mapping={0: 50, 1: 29, 2: 10})) outputs: <xarray.Dataset> Dimensions: (t: 3) Dimensions without coordinates: t Data variables: test (t) int64 50 29 10 ```

{
    "total_count": 3,
    "+1": 3,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
441342986 https://github.com/pydata/xarray/issues/2568#issuecomment-441342986 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDQ0MTM0Mjk4Ng== ahuang11 15331990 2018-11-24T04:34:17Z 2018-11-24T04:34:17Z CONTRIBUTOR

I guess I'm thinking about more complex cases such as changing 0 -> 50, 1 -> 29, 2 -> 10

ds = xr.Dataset({'test': [0, 1, 2]}) ds.where((ds != 1) & (ds != 2), 50)

Thoughts on simplifying this?

{
    "total_count": 3,
    "+1": 3,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783
441340466 https://github.com/pydata/xarray/issues/2568#issuecomment-441340466 https://api.github.com/repos/pydata/xarray/issues/2568 MDEyOklzc3VlQ29tbWVudDQ0MTM0MDQ2Ng== shoyer 1217238 2018-11-24T03:23:43Z 2018-11-24T03:23:43Z MEMBER

The usual way to do this in xarray would be to use where(), e.g., xarray.where(ds == 0, 1, ds) or ds.where(ds == 0, 1).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Xarray equivalent of np.place or df.map(mapping)? 383945783

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 13.294ms · About: xarray-datasette