From b2003777fbc7f5df422f7f5b024dc01f4a572b37 Mon Sep 17 00:00:00 2001 From: theOehrly Date: Tue, 31 May 2022 16:58:16 +0200 Subject: [PATCH 1/2] remove unreachable code in DataFrame.quantile --- pandas/core/frame.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 52857fed5b95f..c695c04052f9d 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -10936,10 +10936,8 @@ def quantile( if needs_i8_conversion(cdtype): dtype = cdtype - if is_list_like(q): - res = self._constructor([], index=q, columns=cols, dtype=dtype) - return res.__finalize__(self, method="quantile") - return self._constructor_sliced([], index=cols, name=q, dtype=dtype) + res = self._constructor([], index=q, columns=cols, dtype=dtype) + return res.__finalize__(self, method="quantile") res = data._mgr.quantile(qs=q, axis=1, interpolation=interpolation) From 46a2340dad52be7e283a7ff47ca074025c1324a0 Mon Sep 17 00:00:00 2001 From: theOehrly Date: Tue, 31 May 2022 17:38:14 +0200 Subject: [PATCH 2/2] add test for increased coverage --- pandas/tests/generic/test_finalize.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index 540a30e691d3c..6901d415a5ae7 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -262,6 +262,13 @@ operator.methodcaller("quantile", numeric_only=False), ), ), + pytest.param( + ( + pd.DataFrame, + ({"A": [np.datetime64("2022-01-01"), np.datetime64("2022-01-02")]},), + operator.methodcaller("quantile", numeric_only=True), + ), + ), ( pd.DataFrame, ({"A": [1]}, [pd.Period("2000", "D")]),