home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

4 rows where issue = 419543087 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

  • lanougue 2
  • shoyer 1
  • AdrianSosic 1

author_association 2

  • NONE 3
  • MEMBER 1

issue 1

  • [Feature Request] iteration equivalent numpy's nditer or ndenumerate · 4 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1255029201 https://github.com/pydata/xarray/issues/2805#issuecomment-1255029201 https://api.github.com/repos/pydata/xarray/issues/2805 IC_kwDOAMm_X85KzjnR lanougue 32069530 2022-09-22T13:30:26Z 2022-09-22T16:12:47Z NONE

Hello guys,

While waiting for a integrated solution. Here is a function that should do the job in a safe way. It returns an iterator

```` def xndindex(ds, dims=None): if dims is None: dims = ds.dims elif type(dims) is str: dims=[dims] else: pass

for d in dims:
    if d not in ds.dims:
        raise ValueError("Invalid dimension '{}'. Available dimensions {}".format(d, ds.dims))

iter_dict = {k:v for k,v in ds.sizes.items() if k in dims}
for d,k in zip(repeat(tuple(iter_dict.keys())),zip(np.ndindex(tuple(iter_dict.values())))):
    yield {k:l for k,l in zip(d,k[0])}

Example of use a = xr.DataArray(np.random.rand(4,3), dims=['x','y'], coords={'x':np.arange(4), 'y':np.arange(3)}) for i in xndindex(a): print(a[i]) ````

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  [Feature Request] iteration equivalent numpy's nditer or ndenumerate 419543087
1239645797 https://github.com/pydata/xarray/issues/2805#issuecomment-1239645797 https://api.github.com/repos/pydata/xarray/issues/2805 IC_kwDOAMm_X85J435l lanougue 32069530 2022-09-07T16:53:34Z 2022-09-07T17:00:44Z NONE

Hi guys,

For now, when I want to iterate over all my dataset I use the simple (but dangerous I believe) workaround: for i in np.ndindex(ds.shape): res = ds[{d:j for d,j in zip(ds.dims,i)}] but, I am not sure that ndindex will iterate in the good order relatively to the ds.dims return.

Is there any news on this topic ?

Many thanks !

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  [Feature Request] iteration equivalent numpy's nditer or ndenumerate 419543087
471978276 https://github.com/pydata/xarray/issues/2805#issuecomment-471978276 https://api.github.com/repos/pydata/xarray/issues/2805 MDEyOklzc3VlQ29tbWVudDQ3MTk3ODI3Ng== AdrianSosic 23265127 2019-03-12T12:23:23Z 2019-03-12T12:23:23Z NONE

Hi shoyer, many thanks for your quick reply. Converting the xarray to a DataFrame indeed does the job and I will use this solution for the time being. Nevertheless, to me the approach seems rather like an ad-hoc solution since it requires a series of conversions / function calls and I feel like there should be some built-in solution from xarray. In particular, in the above solution, you lose track of what are the coordinates and what is the actual data (all is stored in a single NamedTuple), which requires an additional step to separate the two data structures. Anyway, thanks for your help! If you find another solution, please let me know!

{
    "total_count": 3,
    "+1": 3,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  [Feature Request] iteration equivalent numpy's nditer or ndenumerate 419543087
471768511 https://github.com/pydata/xarray/issues/2805#issuecomment-471768511 https://api.github.com/repos/pydata/xarray/issues/2805 MDEyOklzc3VlQ29tbWVudDQ3MTc2ODUxMQ== shoyer 1217238 2019-03-11T22:40:28Z 2019-03-11T22:40:28Z MEMBER

You could convert your data into pandas and use .itertuples(), e.g., ```python import xarray import itertools

ds = xarray.tutorial.open_dataset('air_temperature') records = ds.to_dataframe().reset_index().itertuples(index=False, name='Record') print(list(itertools.islice(records, 5))) Outputs: [Record(lat=75.0, lon=200.0, time=Timestamp('2013-01-01 00:00:00'), air=241.1999969482422), Record(lat=75.0, lon=200.0, time=Timestamp('2013-01-01 06:00:00'), air=242.09999084472656), Record(lat=75.0, lon=200.0, time=Timestamp('2013-01-01 12:00:00'), air=242.29998779296875), Record(lat=75.0, lon=200.0, time=Timestamp('2013-01-01 18:00:00'), air=241.88999938964844), Record(lat=75.0, lon=200.0, time=Timestamp('2013-01-02 00:00:00'), air=243.1999969482422)] ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  [Feature Request] iteration equivalent numpy's nditer or ndenumerate 419543087

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