Skip to content

Commit 7495003

Browse files
committed
DEPR: Specify nodefault for numeric_only default
1 parent 686f052 commit 7495003

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

pandas/core/frame.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@
123123
is_object_dtype,
124124
is_scalar,
125125
is_sequence,
126-
is_timedelta64_dtype,
127126
needs_i8_conversion,
128127
pandas_dtype,
129128
)
@@ -10526,7 +10525,7 @@ def quantile(
1052610525
self,
1052710526
q=0.5,
1052810527
axis: Axis = 0,
10529-
numeric_only: bool = True,
10528+
numeric_only: bool | lib.NoDefault = no_default,
1053010529
interpolation: str = "linear",
1053110530
):
1053210531
"""
@@ -10597,6 +10596,17 @@ def quantile(
1059710596
validate_percentile(q)
1059810597
axis = self._get_axis_number(axis)
1059910598

10599+
if numeric_only is no_default:
10600+
warnings.warn(
10601+
"In future versions of pandas, numeric_only will be set to "
10602+
"False by default, and the datetime/timedelta columns will "
10603+
"be considered in the results. To not consider these columns"
10604+
"specify numeric_only=True and ignore this warning.",
10605+
FutureWarning,
10606+
stacklevel=find_stack_level(),
10607+
)
10608+
numeric_only = True
10609+
1060010610
if not is_list_like(q):
1060110611
# BlockManager.quantile expects listlike, so we wrap and unwrap here
1060210612
res_df = self.quantile(
@@ -10610,19 +10620,6 @@ def quantile(
1061010620
return res.astype(dtype)
1061110621
return res
1061210622

10613-
has_any_datetime_or_timestamp = any(
10614-
is_datetime64_any_dtype(x) or is_timedelta64_dtype(x) for x in self.dtypes
10615-
)
10616-
if numeric_only and has_any_datetime_or_timestamp:
10617-
warnings.warn(
10618-
"In future versions of pandas, numeric_only will be set to "
10619-
"False by default, and the datetime/timedelta columns will "
10620-
"be considered in the results. To not consider these columns"
10621-
"specify numeric_only=True and ignore this warning.",
10622-
FutureWarning,
10623-
stacklevel=find_stack_level(),
10624-
)
10625-
1062610623
q = Index(q, dtype=np.float64)
1062710624
data = self._get_numeric_data() if numeric_only else self
1062810625

0 commit comments

Comments
 (0)