Skip to content

BUG: Change numeric_only default to True #46096

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

Merged
merged 23 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d98e262
BUG: Change numeric_only default to True
NumberPiOso Feb 21, 2022
0db8e52
Add future warning numeric_only in DataFrame.quantile
NumberPiOso Feb 23, 2022
c427795
Add deprecations.quantile_datetime_timedelta_colums in whatsnew
NumberPiOso Feb 23, 2022
fcf37a8
Add stacklevel to warning in DataFrame.quantile
NumberPiOso Feb 23, 2022
7e1d286
Modify test to expect warning in test_quantile.py
NumberPiOso Feb 23, 2022
a5e6def
Ignore FutureWarning at test_quantile.py
NumberPiOso Feb 23, 2022
108bb45
Correct documentation numeric_only inDataFrame.quantile
NumberPiOso Feb 24, 2022
93c5f65
DEPR: Specify nodefault for numeric_only default
NumberPiOso Mar 1, 2022
0f37c30
DEPR: Update whatsnew #7308
NumberPiOso Mar 2, 2022
a324dc9
DEPR: Correct frame.quantile tests to specify numeric_only
NumberPiOso Mar 2, 2022
82db984
DEPR: Correct message error frame.quantile
NumberPiOso Mar 2, 2022
9e9b7a9
DEPR: Remove warning filtering DataFrame.quantile
NumberPiOso Mar 3, 2022
67f2cfa
DEPR: Update whatsnew doc about numeric_only attribute
NumberPiOso Mar 3, 2022
42e7df4
DEPR: Update Examples in docs frame.quantile
NumberPiOso Mar 3, 2022
d0a1221
DEPR: Correct test finalize DataFrame.quantile
NumberPiOso Mar 3, 2022
377cc54
Revert "DEPR: Correct frame.quantile tests to specify numeric_only"
NumberPiOso Mar 8, 2022
b460aa2
DEPR: Update tests of quantile with non num cols"
NumberPiOso Mar 8, 2022
7194d13
DEPR: Raise warning frame.quantile with numeric_only
NumberPiOso Mar 8, 2022
f5f7a3e
DEPR: Update doctests quantile, numeric only
NumberPiOso Mar 8, 2022
16e5fc2
DEPR: Correct test_numeric_only_default_false_warning
NumberPiOso Mar 10, 2022
b88b196
DEPR: Add non numeric test to numeric_only warning
NumberPiOso Mar 10, 2022
db68bf2
DERP: correct_test_produces_warning in frame.quantile
NumberPiOso Mar 10, 2022
4438118
Merge remote-tracking branch 'upstream/main' into ench-quantile-numer…
NumberPiOso Mar 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG: Change numeric_only default to True
  • Loading branch information
NumberPiOso committed Mar 9, 2022
commit d98e262a58a5eaeb108231487be421d6260c33dd
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ Numeric
- Bug in operations with array-likes with ``dtype="boolean"`` and :attr:`NA` incorrectly altering the array in-place (:issue:`45421`)
- Bug in division, ``pow`` and ``mod`` operations on array-likes with ``dtype="boolean"`` not being like their ``np.bool_`` counterparts (:issue:`46063`)
- Bug in multiplying a :class:`Series` with ``IntegerDtype`` or ``FloatingDtype`` by an array-like with ``timedelta64[ns]`` dtype incorrectly raising (:issue:`45622`)
- Bug in :meth:`DataFrame.quantile` attribute ``numeric_only"`` should default False (:issue:`7308`)
-

Conversion
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10558,7 +10558,7 @@ def quantile(
self,
q=0.5,
axis: Axis = 0,
numeric_only: bool = True,
numeric_only: bool = False,
interpolation: str = "linear",
):
"""
Expand All @@ -10570,7 +10570,7 @@ def quantile(
Value between 0 <= q <= 1, the quantile(s) to compute.
axis : {0, 1, 'index', 'columns'}, default 0
Equals 0 or 'index' for row-wise, 1 or 'columns' for column-wise.
numeric_only : bool, default True
numeric_only : bool, default False
If False, the quantile of datetime and timedelta data will be
computed as well.
interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
Expand Down
17 changes: 17 additions & 0 deletions pandas/tests/frame/methods/test_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@


class TestDataFrameQuantile:
def test_numeric_only_default_false(self):
# GH #7308
df = DataFrame({"A": [1, 2, 3], "B": [2, 3, 4]})
df["C"] = pd.date_range("2014-01-01", periods=3, freq="m")

df_expected_num_only_false = Series(
[2.0, 3.0, Timestamp("2014-02-28 00:00:00")],
index=["A", "B", "C"],
name=0.5,
)
tm.assert_series_equal(df.quantile(0.5), df_expected_num_only_false)

df_expected_num_only_true = Series([2.0, 3.0], index=["A", "B"], name=0.5)
tm.assert_series_equal(
df.quantile(0.5, numeric_only=True), df_expected_num_only_true
)

@pytest.mark.parametrize(
"df,expected",
[
Expand Down