Skip to content

Commit 18ae84c

Browse files
mroeschkejorisvandenbossche
authored andcommitted
DOC: Add numeric_only to DataFrame.quantile (#21214)
(cherry picked from commit 7c522bf)
1 parent 957c5a4 commit 18ae84c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pandas/core/frame.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -7089,6 +7089,9 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
70897089
0 <= q <= 1, the quantile(s) to compute
70907090
axis : {0, 1, 'index', 'columns'} (default 0)
70917091
0 or 'index' for row-wise, 1 or 'columns' for column-wise
7092+
numeric_only : boolean, default True
7093+
If False, the quantile of datetime and timedelta data will be
7094+
computed as well
70927095
interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
70937096
.. versionadded:: 0.18.0
70947097
@@ -7116,7 +7119,7 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
71167119
--------
71177120
71187121
>>> df = pd.DataFrame(np.array([[1, 1], [2, 10], [3, 100], [4, 100]]),
7119-
columns=['a', 'b'])
7122+
columns=['a', 'b'])
71207123
>>> df.quantile(.1)
71217124
a 1.3
71227125
b 3.7
@@ -7126,6 +7129,20 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
71267129
0.1 1.3 3.7
71277130
0.5 2.5 55.0
71287131
7132+
Specifying `numeric_only=False` will also compute the quantile of
7133+
datetime and timedelta data.
7134+
7135+
>>> df = pd.DataFrame({'A': [1, 2],
7136+
'B': [pd.Timestamp('2010'),
7137+
pd.Timestamp('2011')],
7138+
'C': [pd.Timedelta('1 days'),
7139+
pd.Timedelta('2 days')]})
7140+
>>> df.quantile(0.5, numeric_only=False)
7141+
A 1.5
7142+
B 2010-07-02 12:00:00
7143+
C 1 days 12:00:00
7144+
Name: 0.5, dtype: object
7145+
71297146
See Also
71307147
--------
71317148
pandas.core.window.Rolling.quantile

0 commit comments

Comments
 (0)