Skip to content

Commit 07cc3be

Browse files
Moisanjreback
authored andcommitted
DOC: fix pandas.DataFrame.quantile docstring and doctests (#23936)
1 parent 93e9be6 commit 07cc3be

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

ci/code_checks.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
175175

176176
MSG='Doctests frame.py' ; echo $MSG
177177
pytest -q --doctest-modules pandas/core/frame.py \
178-
-k"-axes -combine -itertuples -join -pivot_table -quantile -query -reindex -reindex_axis -round"
178+
-k"-axes -combine -itertuples -join -pivot_table -query -reindex -reindex_axis -round"
179179
RET=$(($RET + $?)) ; echo $MSG "DONE"
180180

181181
MSG='Doctests series.py' ; echo $MSG

pandas/core/frame.py

+14-15
Original file line numberDiff line numberDiff line change
@@ -7463,15 +7463,13 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
74637463
Parameters
74647464
----------
74657465
q : float or array-like, default 0.5 (50% quantile)
7466-
0 <= q <= 1, the quantile(s) to compute
7466+
Value between 0 <= q <= 1, the quantile(s) to compute.
74677467
axis : {0, 1, 'index', 'columns'} (default 0)
7468-
0 or 'index' for row-wise, 1 or 'columns' for column-wise
7469-
numeric_only : boolean, default True
7468+
Equals 0 or 'index' for row-wise, 1 or 'columns' for column-wise.
7469+
numeric_only : bool, default True
74707470
If False, the quantile of datetime and timedelta data will be
7471-
computed as well
7471+
computed as well.
74727472
interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
7473-
.. versionadded:: 0.18.0
7474-
74757473
This optional parameter specifies the interpolation method to use,
74767474
when the desired quantile lies between two data points `i` and `j`:
74777475
@@ -7482,6 +7480,8 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
74827480
* nearest: `i` or `j` whichever is nearest.
74837481
* midpoint: (`i` + `j`) / 2.
74847482
7483+
.. versionadded:: 0.18.0
7484+
74857485
Returns
74867486
-------
74877487
quantiles : Series or DataFrame
@@ -7494,18 +7494,17 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
74947494
74957495
See Also
74967496
--------
7497-
pandas.core.window.Rolling.quantile
7498-
numpy.percentile
7497+
core.window.Rolling.quantile: Rolling quantile.
7498+
numpy.percentile: Numpy function to compute the percentile.
74997499
75007500
Examples
75017501
--------
7502-
75037502
>>> df = pd.DataFrame(np.array([[1, 1], [2, 10], [3, 100], [4, 100]]),
7504-
columns=['a', 'b'])
7503+
... columns=['a', 'b'])
75057504
>>> df.quantile(.1)
75067505
a 1.3
75077506
b 3.7
7508-
dtype: float64
7507+
Name: 0.1, dtype: float64
75097508
>>> df.quantile([.1, .5])
75107509
a b
75117510
0.1 1.3 3.7
@@ -7515,10 +7514,10 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
75157514
datetime and timedelta data.
75167515
75177516
>>> df = pd.DataFrame({'A': [1, 2],
7518-
'B': [pd.Timestamp('2010'),
7519-
pd.Timestamp('2011')],
7520-
'C': [pd.Timedelta('1 days'),
7521-
pd.Timedelta('2 days')]})
7517+
... 'B': [pd.Timestamp('2010'),
7518+
... pd.Timestamp('2011')],
7519+
... 'C': [pd.Timedelta('1 days'),
7520+
... pd.Timedelta('2 days')]})
75227521
>>> df.quantile(0.5, numeric_only=False)
75237522
A 1.5
75247523
B 2010-07-02 12:00:00

0 commit comments

Comments
 (0)