Skip to content

Commit 3bf2cb1

Browse files
authored
[CLN] call __finalize__ in quantile (#47183)
* remove unreachable code in DataFrame.quantile * add test for increased coverage
1 parent a4e3338 commit 3bf2cb1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pandas/core/frame.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -10936,10 +10936,8 @@ def quantile(
1093610936
if needs_i8_conversion(cdtype):
1093710937
dtype = cdtype
1093810938

10939-
if is_list_like(q):
10940-
res = self._constructor([], index=q, columns=cols, dtype=dtype)
10941-
return res.__finalize__(self, method="quantile")
10942-
return self._constructor_sliced([], index=cols, name=q, dtype=dtype)
10939+
res = self._constructor([], index=q, columns=cols, dtype=dtype)
10940+
return res.__finalize__(self, method="quantile")
1094310941

1094410942
res = data._mgr.quantile(qs=q, axis=1, interpolation=interpolation)
1094510943

pandas/tests/generic/test_finalize.py

+7
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@
262262
operator.methodcaller("quantile", numeric_only=False),
263263
),
264264
),
265+
pytest.param(
266+
(
267+
pd.DataFrame,
268+
({"A": [np.datetime64("2022-01-01"), np.datetime64("2022-01-02")]},),
269+
operator.methodcaller("quantile", numeric_only=True),
270+
),
271+
),
265272
(
266273
pd.DataFrame,
267274
({"A": [1]}, [pd.Period("2000", "D")]),

0 commit comments

Comments
 (0)