-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
quantile: rename interpolation arg to method #6108
Changes from 9 commits
090b49b
ea5dcf2
cb8d24e
7d074d2
bfe4857
dcfa900
545e4d8
7bea46f
a8bd471
c304977
0e5e4d3
8fe04af
a74e8ec
938a621
e4b3c3c
5d5502a
a4881de
cb929d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ | |
from .indexes import Index, Indexes, default_indexes, propagate_indexes | ||
from .indexing import is_fancy_indexer | ||
from .merge import PANDAS_TYPES, MergeError, _extract_indexes_from_coords | ||
from .npcompat import ArrayLike | ||
from .options import OPTIONS, _get_keep_attrs | ||
from .utils import ( | ||
Default, | ||
|
@@ -3433,11 +3434,12 @@ def sortby( | |
|
||
def quantile( | ||
self, | ||
q: Any, | ||
dim: Union[Hashable, Sequence[Hashable], None] = None, | ||
interpolation: str = "linear", | ||
q: ArrayLike, | ||
dim: Union[str, Sequence[Hashable], None] = None, | ||
method: str = "linear", | ||
keep_attrs: bool = None, | ||
skipna: bool = True, | ||
interpolation: str = None, | ||
) -> "DataArray": | ||
"""Compute the qth quantile of the data along the specified dimension. | ||
|
||
|
@@ -3449,18 +3451,13 @@ def quantile( | |
Quantile to compute, which must be between 0 and 1 inclusive. | ||
dim : hashable or sequence of hashable, optional | ||
Dimension(s) over which to apply quantile. | ||
interpolation : {"linear", "lower", "higher", "midpoint", "nearest"}, default: "linear" | ||
dcherian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
method : str, default: "linear" | ||
This optional parameter specifies the interpolation method to | ||
use when the desired quantile lies between two data points | ||
``i < j``: | ||
|
||
- linear: ``i + (j - i) * fraction``, where ``fraction`` is | ||
the fractional part of the index surrounded by ``i`` and | ||
``j``. | ||
- lower: ``i``. | ||
- higher: ``j``. | ||
- nearest: ``i`` or ``j``, whichever is nearest. | ||
- midpoint: ``(i + j) / 2``. | ||
use when the desired quantile lies between two data points. | ||
See numpy.quantile for available methods. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this ok or should we list them explicitly? (The available methods depend on the numpy version which makes this a bit difficult). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would lean toward listing the current available methods but if not, we should make sure |
||
|
||
This argument was previously called "interpolation", renamed in accordance | ||
with numpy version 1.22.0. | ||
keep_attrs : bool, optional | ||
If True, the dataset's attributes (`attrs`) will be copied from | ||
the original object to the new one. If False (default), the new | ||
|
@@ -3518,8 +3515,9 @@ def quantile( | |
q, | ||
dim=dim, | ||
keep_attrs=keep_attrs, | ||
interpolation=interpolation, | ||
method=method, | ||
skipna=skipna, | ||
interpolation=interpolation, | ||
) | ||
return self._from_temp_dataset(ds) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use
Literal["linear", etc]
here instead ofstr
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that's a bit over the top - can I get away without it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree it would be cool, definitely fine without out too! :)