home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

5 rows where issue = 453576041 and user = 21049064 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

  • tommylees112 · 5 ✖

issue 1

  • assign values from `xr.groupby_bins` to new `variable` · 5 ✖

author_association 1

  • NONE 5
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
508995157 https://github.com/pydata/xarray/issues/3004#issuecomment-508995157 https://api.github.com/repos/pydata/xarray/issues/3004 MDEyOklzc3VlQ29tbWVudDUwODk5NTE1Nw== tommylees112 21049064 2019-07-07T12:17:45Z 2019-07-07T12:17:45Z NONE

Perfect thankyou!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  assign values from `xr.groupby_bins` to new `variable` 453576041
500165601 https://github.com/pydata/xarray/issues/3004#issuecomment-500165601 https://api.github.com/repos/pydata/xarray/issues/3004 MDEyOklzc3VlQ29tbWVudDUwMDE2NTYwMQ== tommylees112 21049064 2019-06-08T21:28:34Z 2019-06-08T21:28:34Z NONE

The best way I have found so far is: df = rank_norm.to_dataframe() bins = pd.qcut(df['rank_norm'], 5, labels=[1, 2, 3, 4, 5]) output = bins.to_xarray().to_dataset().rename({'rank_norm':'rank_quantile'})

Which returns: <xarray.Dataset> Dimensions: (lat: 10, lon: 10, time: 70) Coordinates: * lat (lat) float64 -5.175 -5.125 -5.075 ... -4.825 -4.775 -4.725 * lon (lon) float64 33.52 33.57 33.62 33.67 ... 33.87 33.92 33.97 * time (time) datetime64[ns] 2010-02-28 2010-03-31 ... 2015-11-30 Data variables: rank_quantile (lat, lon, time) int64 2 1 1 1 2 2 1 1 1 ... 1 1 2 2 1 4 2 2

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  assign values from `xr.groupby_bins` to new `variable` 453576041
499959555 https://github.com/pydata/xarray/issues/3004#issuecomment-499959555 https://api.github.com/repos/pydata/xarray/issues/3004 MDEyOklzc3VlQ29tbWVudDQ5OTk1OTU1NQ== tommylees112 21049064 2019-06-07T16:53:55Z 2019-06-08T21:11:46Z NONE

So if I want them separated into 5 percentiles (0, 20) (20,40) (40,60) (60,80) (80,100)

bins = [-0.01, 20., 40., 60., 80., np.Inf] bin_labels = ['1', '2', '3', '4, '5']

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  assign values from `xr.groupby_bins` to new `variable` 453576041
499961306 https://github.com/pydata/xarray/issues/3004#issuecomment-499961306 https://api.github.com/repos/pydata/xarray/issues/3004 MDEyOklzc3VlQ29tbWVudDQ5OTk2MTMwNg== tommylees112 21049064 2019-06-07T16:59:12Z 2019-06-07T16:59:12Z NONE

Also how do I assign the result of the xarray.core.groupby.DatasetGroupBy and the labels to a new variable?

bin_labels = ['20', '40', '60', '80'] decile_index_gpby = rank_norm.groupby_bins('rank_norm', bins=bins, labels=bin_labels) decile_index_gpby.assign() # assign_coords()

Gives me the error message: ```


ValueError Traceback (most recent call last) <ipython-input-6-0c8328bf2f77> in <module> ----> 1 decile_index_gpby = rank_norm.groupby_bins('rank_norm', bins=bins, labels=bin_labels) 2 decile_index_gpby.assign() # assign_coords()

~/miniconda3/lib/python3.7/site-packages/xarray/core/common.py in groupby_bins(self, group, bins, right, labels, precision, include_lowest, squeeze) 529 cut_kwargs={'right': right, 'labels': labels, 530 'precision': precision, --> 531 'include_lowest': include_lowest}) 532 533 def rolling(self, dim=None, min_periods=None, center=False, **dim_kwargs):

~/miniconda3/lib/python3.7/site-packages/xarray/core/groupby.py in init(self, obj, group, squeeze, grouper, bins, cut_kwargs) 249 250 if bins is not None: --> 251 binned = pd.cut(group.values, bins, **cut_kwargs) 252 new_dim_name = group.name + '_bins' 253 group = DataArray(binned, group.coords, name=new_dim_name)

~/miniconda3/lib/python3.7/site-packages/pandas/core/reshape/tile.py in cut(x, bins, right, labels, retbins, precision, include_lowest, duplicates) 239 include_lowest=include_lowest, 240 dtype=dtype, --> 241 duplicates=duplicates) 242 243 return _postprocess_for_cut(fac, bins, retbins, x_is_series,

~/miniconda3/lib/python3.7/site-packages/pandas/core/reshape/tile.py in _bins_to_cuts(x, bins, right, labels, precision, include_lowest, dtype, duplicates) 357 else: 358 if len(labels) != len(bins) - 1: --> 359 raise ValueError('Bin labels must be one fewer than ' 360 'the number of bin edges') 361 if not is_categorical_dtype(labels):

ValueError: Bin labels must be one fewer than the number of bin edges

In [7]: bin_labels = ['20', '40', '60', '80'] ...: decile_index_gpby = rank_norm.groupby_bins('rank_norm', bins=bins, labels=bin_labels) ...: decile_index_gpby.assign() # assign_coords() ...:


IndexError Traceback (most recent call last) <ipython-input-7-a4ba78018478> in <module> 1 bin_labels = ['20', '40', '60', '80'] 2 decile_index_gpby = rank_norm.groupby_bins('rank_norm', bins=bins, labels=bin_labels) ----> 3 decile_index_gpby.assign() # assign_coords()

~/miniconda3/lib/python3.7/site-packages/xarray/core/groupby.py in assign(self, kwargs) 772 Dataset.assign 773 """ --> 774 return self.apply(lambda ds: ds.assign(kwargs)) 775 776

~/miniconda3/lib/python3.7/site-packages/xarray/core/groupby.py in apply(self, func, args, kwargs) 684 kwargs.pop('shortcut', None) # ignore shortcut if set (for now) 685 applied = (func(ds, *args, kwargs) for ds in self._iter_grouped()) --> 686 return self._combine(applied) 687 688 def _combine(self, applied):

~/miniconda3/lib/python3.7/site-packages/xarray/core/groupby.py in _combine(self, applied) 691 coord, dim, positions = self._infer_concat_args(applied_example) 692 combined = concat(applied, dim) --> 693 combined = _maybe_reorder(combined, dim, positions) 694 if coord is not None: 695 combined[coord.name] = coord

~/miniconda3/lib/python3.7/site-packages/xarray/core/groupby.py in _maybe_reorder(xarray_obj, dim, positions) 468 469 def _maybe_reorder(xarray_obj, dim, positions): --> 470 order = _inverse_permutation_indices(positions) 471 472 if order is None:

~/miniconda3/lib/python3.7/site-packages/xarray/core/groupby.py in _inverse_permutation_indices(positions) 110 positions = [np.arange(sl.start, sl.stop, sl.step) for sl in positions] 111 --> 112 indices = nputils.inverse_permutation(np.concatenate(positions)) 113 return indices 114

~/miniconda3/lib/python3.7/site-packages/xarray/core/nputils.py in inverse_permutation(indices) 58 # use intp instead of int64 because of windows :( 59 inverse_permutation = np.empty(len(indices), dtype=np.intp) ---> 60 inverse_permutation[indices] = np.arange(len(indices), dtype=np.intp) 61 return inverse_permutation 62

IndexError: index 1204 is out of bounds for axis 0 with size 1000 ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  assign values from `xr.groupby_bins` to new `variable` 453576041
499958420 https://github.com/pydata/xarray/issues/3004#issuecomment-499958420 https://api.github.com/repos/pydata/xarray/issues/3004 MDEyOklzc3VlQ29tbWVudDQ5OTk1ODQyMA== tommylees112 21049064 2019-06-07T16:50:36Z 2019-06-07T16:50:36Z NONE

Why does the number of bin labels have to be one less than the number of bins?

``` bin_labels = ['20', '40', '60', '80', '100'] decile_index_gpby = rank_norm.groupby_bins('rank_norm', bins=bins, labels=bin_labels)

Out[]: ValueError: Bin labels must be one fewer than the number of bin edges ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  assign values from `xr.groupby_bins` to new `variable` 453576041

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