Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quantile method to GroupBy #2828

Merged
merged 15 commits into from
Jun 24, 2019
Merged

Add quantile method to GroupBy #2828

merged 15 commits into from
Jun 24, 2019

Conversation

huard
Copy link
Contributor

@huard huard commented Mar 20, 2019

  • Tests added
  • Fully documented, including whats-new.rst for all changes and api.rst for new API

Fixes #3018

Note that I've added an unrelated test that exposes an issue with grouping when there is only one element per group.

@huard
Copy link
Contributor Author

huard commented Mar 20, 2019

I just realized that I could do
da.groupby('time.month').apply(xr.DataArray.quantile, q=.5, dim='time')
which seems to yield the same results.

@shoyer
Copy link
Member

shoyer commented Mar 20, 2019

I just realized that I could do
da.groupby('time.month').apply(xr.DataArray.quantile, q=.5, dim='time')
which seems to yield the same results.

Yes, I think this would be the preferred way to implement this :)

@huard
Copy link
Contributor Author

huard commented Mar 21, 2019

Made the change.
I had to drop the quantile dimension for scalar q after the apply to maintain the same behavior as DataArray.quantile, but it got me wondering if keeping the quantile dimension even for scalar q should not be the default.

xarray/core/groupby.py Outdated Show resolved Hide resolved
xarray/tests/test_groupby.py Outdated Show resolved Hide resolved
@pep8speaks
Copy link

pep8speaks commented Jun 12, 2019

Hello @huard! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-06-24 15:19:40 UTC

@dcherian
Copy link
Contributor

LGTM.

@shoyer shoyer merged commit b054c31 into pydata:master Jun 24, 2019
@shoyer
Copy link
Member

shoyer commented Jun 24, 2019

Thanks @huard !

dcherian added a commit to dcherian/xarray that referenced this pull request Jun 24, 2019
* master: (31 commits)
  Add quantile method to GroupBy (pydata#2828)
  rolling_exp (nee ewm) (pydata#2650)
  Ensure explicitly indexed arrays are preserved (pydata#3027)
  add back dask-dev tests (pydata#3025)
  ENH: keepdims=True for xarray reductions (pydata#3033)
  Revert cmap fix (pydata#3038)
  Add "errors" keyword argument to drop() and drop_dims() (pydata#2994) (pydata#3028)
  More consistency checks (pydata#2859)
  Check types in travis (pydata#3024)
  Update issue templates (pydata#3019)
  Add pytest markers to avoid warnings (pydata#3023)
  Feature/merge errormsg (pydata#2971)
  More support for missing_value. (pydata#2973)
  Use flake8 rather than pycodestyle (pydata#3010)
  Pandas labels deprecation (pydata#3016)
  Pytest capture uses match, not message (pydata#3011)
  dask-dev tests to allowed failures in travis (pydata#3014)
  Fix 'to_masked_array' computing dask arrays twice (pydata#3006)
  str accessor (pydata#2991)
  fix safe_cast_to_index (pydata#3001)
  ...
@keewis keewis mentioned this pull request Nov 13, 2019
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add quantile method to groupby object
4 participants