Skip to content

Commit 93c5f65

Browse files
committed
DEPR: Specify nodefault for numeric_only default
1 parent 108bb45 commit 93c5f65

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
@@ -122,7 +122,6 @@
122122
is_object_dtype,
123123
is_scalar,
124124
is_sequence,
125-
is_timedelta64_dtype,
126125
needs_i8_conversion,
127126
pandas_dtype,
128127
)
@@ -10559,7 +10558,7 @@ def quantile(
1055910558
self,
1056010559
q=0.5,
1056110560
axis: Axis = 0,
10562-
numeric_only: bool = True,
10561+
numeric_only: bool | lib.NoDefault = no_default,
1056310562
interpolation: str = "linear",
1056410563
):
1056510564
"""
@@ -10630,6 +10629,17 @@ def quantile(
1063010629
validate_percentile(q)
1063110630
axis = self._get_axis_number(axis)
1063210631

10632+
if numeric_only is no_default:
10633+
warnings.warn(
10634+
"In future versions of pandas, numeric_only will be set to "
10635+
"False by default, and the datetime/timedelta columns will "
10636+
"be considered in the results. To not consider these columns"
10637+
"specify numeric_only=True and ignore this warning.",
10638+
FutureWarning,
10639+
stacklevel=find_stack_level(),
10640+
)
10641+
numeric_only = True
10642+
1063310643
if not is_list_like(q):
1063410644
# BlockManager.quantile expects listlike, so we wrap and unwrap here
1063510645
res_df = self.quantile(
@@ -10643,19 +10653,6 @@ def quantile(
1064310653
return res.astype(dtype)
1064410654
return res
1064510655

10646-
has_any_datetime_or_timestamp = any(
10647-
is_datetime64_any_dtype(x) or is_timedelta64_dtype(x) for x in self.dtypes
10648-
)
10649-
if numeric_only and has_any_datetime_or_timestamp:
10650-
warnings.warn(
10651-
"In future versions of pandas, numeric_only will be set to "
10652-
"False by default, and the datetime/timedelta columns will "
10653-
"be considered in the results. To not consider these columns"
10654-
"specify numeric_only=True and ignore this warning.",
10655-
FutureWarning,
10656-
stacklevel=find_stack_level(),
10657-
)
10658-
1065910656
q = Index(q, dtype=np.float64)
1066010657
data = self._get_numeric_data() if numeric_only else self
1066110658

0 commit comments

Comments
 (0)