home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

5 rows where author_association = "MEMBER" and issue = 297560256 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 3

  • shoyer 3
  • max-sixty 1
  • fujiisoup 1

issue 1

  • cartesian product of coordinates and using it to index / fill empty dataset · 5 ✖

author_association 1

  • MEMBER · 5 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
396738702 https://github.com/pydata/xarray/issues/1914#issuecomment-396738702 https://api.github.com/repos/pydata/xarray/issues/1914 MDEyOklzc3VlQ29tbWVudDM5NjczODcwMg== shoyer 1217238 2018-06-12T21:23:09Z 2018-06-12T21:23:09Z MEMBER

xyzpy (by @jcmgray) looks like it might be a nice way to solve this problem, e.g., see http://xyzpy.readthedocs.io/en/latest/examples/complex%20output%20example.html

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  cartesian product of coordinates and using it to index / fill empty dataset 297560256
367578341 https://github.com/pydata/xarray/issues/1914#issuecomment-367578341 https://api.github.com/repos/pydata/xarray/issues/1914 MDEyOklzc3VlQ29tbWVudDM2NzU3ODM0MQ== shoyer 1217238 2018-02-22T06:13:58Z 2018-02-22T06:13:58Z MEMBER

This issue has brought up a lot of the same issues: https://github.com/pydata/xarray/issues/1773

Clearly, we need better documentation here at the very least.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  cartesian product of coordinates and using it to index / fill empty dataset 297560256
366884882 https://github.com/pydata/xarray/issues/1914#issuecomment-366884882 https://api.github.com/repos/pydata/xarray/issues/1914 MDEyOklzc3VlQ29tbWVudDM2Njg4NDg4Mg== shoyer 1217238 2018-02-20T07:02:37Z 2018-02-20T07:02:37Z MEMBER

xarray.broadcast() could also be helpful for generating a cartesian product. Something like xarray.broadcast(*data.coords.values()) would get you three 3D DataArray objects.

apply_ufunc with vectorize=True could also achieve what you're looking for here: ```python import xarray as xr import numpy as np

data = xr.Dataset(coords={'x': np.linspace(-1, 1), 'y': np.linspace(0, 10), 'a': 1, 'b': 5})

def some_function(x, y): return float(x) * float(y)

xr.apply_ufunc(some_function, data['x'], data['y'], vectorize=True) Results in: <xarray.DataArray (x: 50, y: 50)> array([[ -0. , -0.204082, -0.408163, ..., -9.591837, -9.795918, -10. ], [ -0. , -0.195752, -0.391504, ..., -9.200333, -9.396085, -9.591837], [ -0. , -0.187422, -0.374844, ..., -8.80883 , -8.996252, -9.183673], ..., [ 0. , 0.187422, 0.374844, ..., 8.80883 , 8.996252, 9.183673], [ 0. , 0.195752, 0.391504, ..., 9.200333, 9.396085, 9.591837], [ 0. , 0.204082, 0.408163, ..., 9.591837, 9.795918, 10. ]]) Coordinates: * x (x) float64 -1.0 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 ... a int64 1 b int64 5 * y (y) float64 0.0 0.2041 0.4082 0.6122 0.8163 1.02 1.224 1.429 ... ```

You can even do this with dask arrays if you set dask='parallelized'.

That said, it does feel like there's some missing functionality here for the xarray equivalent of ndenumerate. I'm not entirely sure what the right API is, yet.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  cartesian product of coordinates and using it to index / fill empty dataset 297560256
366825366 https://github.com/pydata/xarray/issues/1914#issuecomment-366825366 https://api.github.com/repos/pydata/xarray/issues/1914 MDEyOklzc3VlQ29tbWVudDM2NjgyNTM2Ng== fujiisoup 6815844 2018-02-19T23:21:05Z 2018-02-19T23:34:58Z MEMBER

I am not sure if it is efficient to interact with a cluster, but I often use MultiIndex for make a cartesian product, ```python In [1]: import xarray as xr ...: import numpy as np ...: data = xr.DataArray(np.full((3, 4), np.nan), dims=('x', 'y'), ...: coords={'x': [0, 1, 2], 'y': ['a', 'b', 'c', 'd']}) ...: ...: data ...: Out[1]: <xarray.DataArray (x: 3, y: 4)> array([[ nan, nan, nan, nan], [ nan, nan, nan, nan], [ nan, nan, nan, nan]]) Coordinates: * x (x) int64 0 1 2 * y (y) <U1 'a' 'b' 'c' 'd'

In [2]: data1 = data.stack(xy=['x', 'y']) ...: data1 ...: Out[2]: <xarray.DataArray (xy: 12)> array([ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan]) Coordinates: * xy (xy) MultiIndex - x (xy) int64 0 0 0 0 1 1 1 1 2 2 2 2 - y (xy) object 'a' 'b' 'c' 'd' 'a' 'b' 'c' 'd' 'a' 'b' 'c' 'd' For the above example, `data` becomes 1-dimensional with coordinate `xy`, where `xy` is a product of `x` and `y`. Each entry of `xy` is tuple of 'x' and 'y' value,python In [3]: data1[0] Out[3]: <xarray.DataArray ()> array(np.nan) Coordinates: xy object (0, 'a') and we can assign a value for given coordinate values by `loc` method,python In [5]: # Assuming we found the result with (1, 'a') is 2.0 ...: data1.loc[(1, 'a'), ] = 2.0

In [6]: data1 Out[6]: <xarray.DataArray (xy: 12)> array([ nan, nan, nan, nan, 2., nan, nan, nan, nan, nan, nan, nan]) Coordinates: * xy (xy) MultiIndex - x (xy) int64 0 0 0 0 1 1 1 1 2 2 2 2 - y (xy) object 'a' 'b' 'c' 'd' 'a' 'b' 'c' 'd' 'a' 'b' 'c' 'd' ```

Note that we need to access via data1.loc[(1, 'a'), ], rather than data1.loc[(1, 'a')] (last comma in the bracket is needed.)

EDIT: I modified my previous comment to take the partial assignment into accout.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  cartesian product of coordinates and using it to index / fill empty dataset 297560256
366791162 https://github.com/pydata/xarray/issues/1914#issuecomment-366791162 https://api.github.com/repos/pydata/xarray/issues/1914 MDEyOklzc3VlQ29tbWVudDM2Njc5MTE2Mg== max-sixty 5635139 2018-02-19T20:05:53Z 2018-02-19T20:05:53Z MEMBER

I think that this shouldn't be too hard to 'get done' but also that xarray may not give you much help natively. (I'm not sure though, so take this as hopefully helpful contribution rather than a definitive answer)

Specifically, can you do (2) by generating a product of the coords? Either using numpy, stacking, or some simple python:

```python

In [3]: list(product(*((data[x].values) for x in data.dims))) Out[3]: [(0.287706062977495, 0.065327131503921), (0.287706062977495, 0.17398282388217068), (0.287706062977495, 0.1455022501442349), (0.42398126102299216, 0.065327131503921), (0.42398126102299216, 0.17398282388217068), (0.42398126102299216, 0.1455022501442349), (0.13357153947234057, 0.065327131503921), (0.13357153947234057, 0.17398282388217068), (0.13357153947234057, 0.1455022501442349), (0.42347765161572537, 0.065327131503921), (0.42347765161572537, 0.17398282388217068), (0.42347765161572537, 0.1455022501442349)] ```

then distribute those out to a cluster if you need, and then unstack them back into a dataset?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  cartesian product of coordinates and using it to index / fill empty dataset 297560256

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