home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

1 row where issue = 187069161 and user = 7441788 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 1

  • seth-p · 1 ✖

issue 1

  • MultiIndex serialization to NetCDF · 1 ✖

author_association 1

  • CONTRIBUTOR 1
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
436015893 https://github.com/pydata/xarray/issues/1077#issuecomment-436015893 https://api.github.com/repos/pydata/xarray/issues/1077 MDEyOklzc3VlQ29tbWVudDQzNjAxNTg5Mw== seth-p 7441788 2018-11-05T20:03:48Z 2018-11-05T20:03:48Z CONTRIBUTOR

This code isn't particularly pretty, and I'm not sure if it handles all cases, but it enables serialization of MultiIndex indices by calling ds.mi.encode_multiindices() before serializing and ds.mi.decode_multiindices() after deserializing.

``` @xr.register_dataset_accessor('mi') class MiscDatasetAccessor(): def init(self, xarray_obj): self._obj = xarray_obj

def encode_multiindices(self):
    result = self._obj
    for name, index in list(self._obj.indexes.items()):
        if isinstance(index, pd.MultiIndex):
            temp_name = '__' + name
            new_coords = {'{}__{}'.format(temp_name, level_name): level_values.rename(None)
                          for level_name, level_values in zip(index.names, index.levels)}
            new_coords[temp_name] = xr.DataArray(index.labels,
                                                 dims=('{}__names__'.format(temp_name),
                                                       '{}__num__'.format(temp_name)),
                                                 coords={'{}__names__'.format(temp_name): index.names,
                                                         '{}__num__'.format(temp_name): list(range(len(index)))},
                                                 attrs={'__is_multiindex': 1})
            result = result.drop(name).assign_coords(**new_coords)
    return result

def decode_multiindices(self):
    result = self._obj
    for temp_name, da in list(self._obj.coords.items()):
        if temp_name.startswith('__') and da.attrs.get('__is_multiindex', False):
            name = temp_name[2:]
            level_names = da.coords['{}__names__'.format(temp_name)].values
            levels = [result.coords['{}__{}'.format(temp_name, level_name)].values for level_name in level_names]
            labels = da.values
            result = result.assign_coords(**{name: pd.MultiIndex(levels=levels, labels=labels, names=level_names)})
            result = result.drop(['{}__{}'.format(temp_name, level_name) for level_name in level_names] +
                                 list(da.dims) + [temp_name])
    return result

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  MultiIndex serialization to NetCDF 187069161

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