home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 566509807

This data as json

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
566509807 MDU6SXNzdWU1NjY1MDk4MDc= 3775 [Question] Efficient shortcut for unstacking only parts of dimension? 1200058 open 0     1 2020-02-17T20:46:03Z 2020-03-07T04:53:05Z   NONE      

Hi all, is there an efficient way to unstack only parts of a MultiIndex?

Consider for example the following array: python <xarray.Dataset> Dimensions: (observations: 17525) Coordinates: * observations (observations) MultiIndex - subtissue (observations) object 'Skin_Sun_Exposed_Lower_leg' ... 'Thyroid' - individual (observations) object 'GTEX-111FC' ... 'GTEX-ZZPU' - gene (observations) object 'ENSG00000140400' ... 'ENSG00000174233' - end (observations) object '5' '5' '5' ... '3' '3' Data variables: fraser_min_pval (observations) float64 dask.array<chunksize=(17525,), meta=np.ndarray> fraser_min_minus_log10_pval (observations) float64 dask.array<chunksize=(17525,), meta=np.ndarray> Here, I have a MultiIndex observations=["subtissue", "individual", "gene", "end"]. However, I would like to have end in its own dimension. Currently, I have to do the following to solve this issue: python3 xrds.unstack("observations").stack(observations=["subtissue", "individual", "gene",]) However, this seems quite inefficient and introduces NaN's.

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 22:33:48) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-1062.1.2.el7.x86_64 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.3 xarray: 0.15.0 pandas: 1.0.0 numpy: 1.17.5 scipy: 1.4.1 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: 2.4.0 cftime: 1.0.4.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.10.1 distributed: 2.10.0 matplotlib: 3.1.3 cartopy: None seaborn: 0.10.0 numbagg: None setuptools: 45.1.0.post20200119 pip: 20.0.2 conda: None pytest: 5.3.5 IPython: 7.12.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3775/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 0.544ms · About: xarray-datasette