|
32 | 32 | from pandas.compat.numpy import function as nv
|
33 | 33 | from pandas.errors import AbstractMethodError
|
34 | 34 | from pandas.util._decorators import Appender, Substitution, rewrite_axis_style_signature
|
35 |
| -from pandas.util._validators import validate_bool_kwarg, validate_fillna_kwargs |
| 35 | +from pandas.util._validators import ( |
| 36 | + validate_bool_kwarg, |
| 37 | + validate_fillna_kwargs, |
| 38 | + validate_percentile, |
| 39 | +) |
36 | 40 |
|
37 | 41 | from pandas.core.dtypes.common import (
|
38 | 42 | ensure_int64,
|
@@ -10168,7 +10172,7 @@ def describe(self, percentiles=None, include=None, exclude=None):
|
10168 | 10172 | percentiles = list(percentiles)
|
10169 | 10173 |
|
10170 | 10174 | # get them all to be in [0, 1]
|
10171 |
| - self._check_percentile(percentiles) |
| 10175 | + validate_percentile(percentiles) |
10172 | 10176 |
|
10173 | 10177 | # median should always be included
|
10174 | 10178 | if 0.5 not in percentiles:
|
@@ -10272,21 +10276,6 @@ def describe_1d(data):
|
10272 | 10276 | d.columns = data.columns.copy()
|
10273 | 10277 | return d
|
10274 | 10278 |
|
10275 |
| - def _check_percentile(self, q): |
10276 |
| - """ |
10277 |
| - Validate percentiles (used by describe and quantile). |
10278 |
| - """ |
10279 |
| - |
10280 |
| - msg = "percentiles should all be in the interval [0, 1]. Try {0} instead." |
10281 |
| - q = np.asarray(q) |
10282 |
| - if q.ndim == 0: |
10283 |
| - if not 0 <= q <= 1: |
10284 |
| - raise ValueError(msg.format(q / 100.0)) |
10285 |
| - else: |
10286 |
| - if not all(0 <= qs <= 1 for qs in q): |
10287 |
| - raise ValueError(msg.format(q / 100.0)) |
10288 |
| - return q |
10289 |
| - |
10290 | 10279 | _shared_docs[
|
10291 | 10280 | "pct_change"
|
10292 | 10281 | ] = """
|
|
0 commit comments