home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

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

  • shoyer 1
  • dcherian 1
  • oliviermarti 1
  • JavierRuano 1

author_association 2

  • MEMBER 2
  • NONE 2

issue 1

  • DataArray attributes not present in DataSet. Coherency problem between DataSet and NetCDF file · 4 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
829638401 https://github.com/pydata/xarray/issues/5208#issuecomment-829638401 https://api.github.com/repos/pydata/xarray/issues/5208 MDEyOklzc3VlQ29tbWVudDgyOTYzODQwMQ== JavierRuano 34353851 2021-04-29T22:33:05Z 2021-04-29T22:33:05Z NONE

import numpy as np import xarray as xr

Creates DataArrays

nt = 4 time = np.arange (nt) * 86400.0 time = xr.DataArray (time, coords=[time,], dims=["time",]) aa = time * 2.0

Adding attributes to DataArrays

time.attrs['units'] = "second" aa.attrs['units'] = "whatever"

Attributes are visible in the DataArrays

print ('----------> time DataArray: ') print (time) print ('----------> aa DataArray : ' ) print (aa) print ('----------> aa attributes : ') print (aa.attrs )

Creating a Dataset

ds = xr.Dataset( { "aa": (["time",], aa), }, coords={"time": (["time",], time), }, )

Attributes are not visible in the Dataset

print ('----------> DataSet before setting attributes') print (ds)

My request #1 : attributes of the DataArrays should be added to the DataSet (may be optional)

print ('----------> Attributes of aa in DataSet : none') print ( ds['aa'].attrs ) print ('----------> Attributes of aa outside DataSet : still here') print ( aa.attrs )

print ('----------> Attributes are not written to the NetCDF file') ds.to_netcdf ('sample1.nc')

Adding attributes directly to the Dataset

Attributes are still not visible in the Dataset

print ('----------> DataSet after setting attributes : attributes not shown' ) ds=ds.assign_attrs({'Visible':'NotInvisibleMan'}) ds['time'].attrs['units']="second" ds['aa'].attrs['units']="whatever"
ds.to_netcdf('safeReturn.nc') print(xr.open_dataset('safeReturn.nc').attrs) print(xr.open_dataset('safeReturn.nc')['aa'].attrs) print(xr.open_dataset('safeReturn.nc')['time'].attrs)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray attributes not present in DataSet. Coherency problem between DataSet and NetCDF file 865003095
828647680 https://github.com/pydata/xarray/issues/5208#issuecomment-828647680 https://api.github.com/repos/pydata/xarray/issues/5208 MDEyOklzc3VlQ29tbWVudDgyODY0NzY4MA== shoyer 1217238 2021-04-28T17:39:56Z 2021-04-28T17:39:56Z MEMBER

You can see variable attributes if you write dataset.info(). They aren't included in the default for print(dataset) because variable attributes can be very long for datasets with many variables.

{
    "total_count": 2,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 1
}
  DataArray attributes not present in DataSet. Coherency problem between DataSet and NetCDF file 865003095
828423751 https://github.com/pydata/xarray/issues/5208#issuecomment-828423751 https://api.github.com/repos/pydata/xarray/issues/5208 MDEyOklzc3VlQ29tbWVudDgyODQyMzc1MQ== oliviermarti 2853966 2021-04-28T12:43:06Z 2021-04-28T12:43:06Z NONE

dcherian, thank you for your help.

But a problem (feature ?) remains : when a Dataset is created, the command print(Dataset) doesn't show variables attributes. But attributes are shown when the Dataset is readed in a NetCDF file. Is there a reason for this difference a behaviour ?

Olivier

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray attributes not present in DataSet. Coherency problem between DataSet and NetCDF file 865003095
824927779 https://github.com/pydata/xarray/issues/5208#issuecomment-824927779 https://api.github.com/repos/pydata/xarray/issues/5208 MDEyOklzc3VlQ29tbWVudDgyNDkyNzc3OQ== dcherian 2448579 2021-04-22T15:10:53Z 2021-04-22T15:10:53Z MEMBER

```

Creating a Dataset

ds = xr.Dataset( { "aa": (["time",], aa), }, coords={"time": (["time",], time), }, ) ```

This syntax recreates the DataArray aa. Since you don't provide attributes in (["time",], aa), the resulting DataArray has no attributes

Instead try ds = xr.Dataset({"aa": aa}) # works when aa is already a DataArray

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  DataArray attributes not present in DataSet. Coherency problem between DataSet and NetCDF file 865003095

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