home / github

Menu
  • GraphQL API
  • Search all tables

issues

Table actions
  • GraphQL API for issues

3 rows where state = "closed" and user = 38346144 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: comments, created_at (date), updated_at (date), closed_at (date)

type 1

  • issue 3

state 1

  • closed · 3 ✖

repo 1

  • xarray 3
id node_id number title user state locked assignee milestone comments created_at updated_at ▲ closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1029088776 I_kwDOAMm_X849VqYI 5874 Need a way to speciefy the names of coordinates from the indices which droped by DataArray.reset_index. weipeng1999 38346144 closed 0     3 2021-10-18T13:04:34Z 2022-09-28T07:27:19Z 2022-09-28T07:26:55Z NONE      

When I try to use some different coordinates as the index of a dim, I notice the new API on v0.9 provided by DataArray.set_index: ```python

import numpy as np import xarray as xr arr = xr.DataArray(np.r_[:4].reshape(4,4),dims=('t','x')) arr['x_str'] = "x",["a","b","c","d"] arr["x_num"] = "x",[1,2,3,4]; arr <xarray.DataArray (t: 4, x: 4)> array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) Coordinates: x_str (x) <U1 'a' 'b' 'c' 'd' x_num (x) int64 1 2 3 4 Dimensions without coordinates: t, x arr.set_index(x='x_str'); arr <xarray.DataArray (t: 4, x: 4)> array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) Coordinates: x_num (x) int64 1 2 3 4 * x (x) object 'a' 'b' 'c' 'd' Dimensions without coordinates: t

... some code with "arr[{'x':[... some str index ...]}]" ...

That's really convenient, what a nice API. But when I want to switch to another coordinate, I found that I can not recovery my arr to the version before I using :python arr=arr.reset_index('x'); arr # why the croodinate to used as index now lose its name "x_str"? <xarray.DataArray (t: 4, x: 4)> array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) Coordinates: x_num (x) int64 1 2 3 4 x_ (x) object 'a' 'b' 'c' 'd' Dimensions without coordinates: t, x arr=arr.set_index(x="x_num");arr # anyway, continue going to the code use coordinate "x_num" as index

... some code with "arr[{'x':[... some int index ...]}]" ...

arr=arr.reset_index('x');arr # now I need "x_str" coordinate as index, here we go <xarray.DataArray (t: 4, x: 4)> array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) Coordinates: x_ (x) int64 1 2 3 4 Dimensions without coordinates: t, x

NOOP!!! the "x_int" coordinate COVER the "x_str" coordinate, I can't access the later any more :(

To solve this problem, I get following ways: - Add new function to do this. - may be most directly way. - add new function to implement and new API to design. - stop the DataArray.set_index to change coordinate name - The benefit is that without new function, its the most convenient one. - But it may change the calling-promise of DataArray.set_index, so it may be useless. - Here are some example to show how it can be used: python arr = arr.set_index({'x':'x_str'})

... some code with "arr[{'x':[... some str index ...]}]" ...

arr = arr.set_index({'x':'x_int'})

... some code with "arr[{'x':[... some int index ...]}]" ...

arr = arr.set_index({'x':'x_str'}) ... - store the coordinate name in DataArray when calling "DataArray.set_index" and recovery them when calling "DataArray.reset_index" - Just a bit more complex than previews one. - But it need to add redundant data inner DataArray, useless too. - Example: python arr = arr.set_index({'x':'x_str'})

... some code with "arr[{'x':[... some str index ...]}]" ...

arr = arr.reset_index('x').set_index({'x':'x_int'})

... some code with "arr[{'x':[... some int index ...]}]" ...

arr = arr.reset_index('x').set_index({'x':'x_str'}) ... - let DataArray.reset_index support Mapping as names parameters, while use the keys as dims to reset indices and the value as the names of coordinates converted from those indices. - More complex. - Maybe the one cause least change, so I prefer it. - Example: python arr = arr.set_index({'x':'x_str'})

... some code with "arr[{'x':[... some str index ...]}]" ...

arr = arr.reset_index({'x':'x_str'}).set_index({'x':'x_int'})

... some code with "arr[{'x':[... some int index ...]}]" ...

arr = arr.reset_index({'x':'x_int'}).set_index({'x':'x_str'}) ... ```

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/5874/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue
495799492 MDU6SXNzdWU0OTU3OTk0OTI= 3322 Linear algebra support weipeng1999 38346144 closed 0     9 2019-09-19T13:27:28Z 2022-04-18T16:14:04Z 2022-04-18T16:14:03Z NONE      

Share we support linear algebra? Thank you for your hardworking, I'm so happy that we do not need to rember the damned "axis number" in normal situations. But sometime we should still use the functions of linear algebra like LUdepart or determinant.
Follow is the codes to explain some personal idea of new functions API.

code

```

Adata = np.random.randn(4,4,7) A = DataArray(Adata, dims=('x','y','z')) L, U = LUdepart(A, dims1='x', dims2='y',newdims='a') ```

result

```

L DataArray(x:4, z:7, a: 4) ... U DataArray(y:4, z:7, a: 4) ... L@U == A True ``` I think other essential linear algebra function in numpy can be wraped by this way so that we will can use their named axis version. Do you have any suggestions? Finally, thankyou again for your work.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3322/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue
866530388 MDU6SXNzdWU4NjY1MzAzODg= 5214 When try to assign a pd.MultiIndex to the coords, the behavior is different between "Dimension coordinate" and "Non-dimension coordinate" weipeng1999 38346144 closed 0     3 2021-04-24T02:47:15Z 2021-09-15T11:04:57Z 2021-09-15T11:04:57Z NONE      

Bug reports that follow these guidelines are easier to diagnose, and so are often handled much more quickly. -->

What happened:

When I try to assign an instance of pd.MultiIndex to the coords: the behavior of "Dimension coordinate" is to maintain the multi-index so I can use multi-index levels directly as keyword arguments, while the behavior of "Non-dimension coordinate" is to change the index to an np.ndarray with dtype "object" , that make above function failed.

What you expected to happen:

I want the "Non-dimension coordinate" can also maintain the multi-index

Minimal Complete Verifiable Example:

```python

import xarray as xr import numpy as np import pandas as pd

create a dataarray named 'arr'

arr = xr.DataArray(np.r_[:6],{},'z')

add coords 'z1' in dim 'z'

this time 'z1' is a "Non-dimension coordinate"

arr.coords['z1'] = 'z',pd.MultiIndex.from_product( ([1,2,3],['a','b']),names=['i','n'] )

let the coords 'z1' to be the z's coords

arr.set_index(z='z1') arr.sel(n='a') # Failed to use index 'n' in multiindex 'z' ValueError: dimensions or multi-index levels ['n'] do not exist

let's see what's coords 'z' look like

arr.z <xarray.DataArray 'z' (z: 6)> array([(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b'), (3, 'a'), (3, 'b')], dtype=object) Coordinates: * z (z) object (1, 'a') (1, 'b') (2, 'a') (2, 'b') (3, 'a') (3, 'b')

why 'z' is not a MultiIndex ???

now 'z' is a "Dimension coordinate"

set the coords again

arr1.coords['z'] = pd.MultiIndex.from_product( ([1,2,3],['a','b']),names=['i','n'] ) arr.sel(n='a') #OK <xarray.DataArray (i: 3)> array([0, 2, 4]) Coordinates: * i (i) int64 1 2 3

let's see what's coords 'z' look like

arr.z <xarray.DataArray 'z' (z: 6)> array([(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b'), (3, 'a'), (3, 'b')], dtype=object) Coordinates: * z (z) MultiIndex - i (z) int64 1 1 2 2 3 3 - n (z) object 'a' 'b' 'a' 'b' 'a' 'b'

'z' is successfully setted to a MultiIndex

```

Anything else we need to know?:

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.8.2 (default, Mar 25 2020, 17:03:02) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 5.10.27-gentoo-dist machine: x86_64 processor: byteorder: little LC_ALL: None LANG: C.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.4 libnetcdf: None xarray: 0.17.0 pandas: 1.2.4 numpy: 1.20.2 scipy: 1.6.2 netCDF4: None pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: None cftime: 1.4.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: 0.9.8.5 iris: None bottleneck: None dask: 2021.04.0 distributed: 2021.04.0 matplotlib: 3.4.1 cartopy: 0.18.0 seaborn: 0.11.1 numbagg: None pint: None setuptools: 49.6.0.post20210108 pip: 21.0.1 conda: 4.10.1 pytest: None IPython: 7.22.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/5214/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue

Advanced export

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

CSV options:

CREATE TABLE [issues] (
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [number] INTEGER,
   [title] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [state] TEXT,
   [locked] INTEGER,
   [assignee] INTEGER REFERENCES [users]([id]),
   [milestone] INTEGER REFERENCES [milestones]([id]),
   [comments] INTEGER,
   [created_at] TEXT,
   [updated_at] TEXT,
   [closed_at] TEXT,
   [author_association] TEXT,
   [active_lock_reason] TEXT,
   [draft] INTEGER,
   [pull_request] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [state_reason] TEXT,
   [repo] INTEGER REFERENCES [repos]([id]),
   [type] TEXT
);
CREATE INDEX [idx_issues_repo]
    ON [issues] ([repo]);
CREATE INDEX [idx_issues_milestone]
    ON [issues] ([milestone]);
CREATE INDEX [idx_issues_assignee]
    ON [issues] ([assignee]);
CREATE INDEX [idx_issues_user]
    ON [issues] ([user]);
Powered by Datasette · Queries took 75.47ms · About: xarray-datasette