From 0bfe4e14f6b1b3eb51d330471183a263e54aa056 Mon Sep 17 00:00:00 2001 From: DG Date: Wed, 30 Nov 2022 08:25:57 +0530 Subject: [PATCH 1/2] remove TypeError intercept in agg --- pandas/core/apply.py | 6 ------ pandas/tests/apply/test_frame_apply.py | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/pandas/core/apply.py b/pandas/core/apply.py index 6d9f5510eb8c5..722de91ba5246 100644 --- a/pandas/core/apply.py +++ b/pandas/core/apply.py @@ -663,12 +663,6 @@ def agg(self): result = None try: result = super().agg() - except TypeError as err: - exc = TypeError( - "DataFrame constructor called with " - f"incompatible data and dtype: {err}" - ) - raise exc from err finally: self.obj = obj self.axis = axis diff --git a/pandas/tests/apply/test_frame_apply.py b/pandas/tests/apply/test_frame_apply.py index 28c776d0a6d35..0b857dc371e9d 100644 --- a/pandas/tests/apply/test_frame_apply.py +++ b/pandas/tests/apply/test_frame_apply.py @@ -1182,7 +1182,7 @@ def test_agg_multiple_mixed_raises(): # sorted index # TODO: GH#49399 will fix error message - msg = "DataFrame constructor called with" + msg = "does not support reduction" with pytest.raises(TypeError, match=msg): mdf.agg(["min", "sum"]) @@ -1283,7 +1283,7 @@ def test_nuiscance_columns(): ) tm.assert_frame_equal(result, expected) - msg = "DataFrame constructor called with incompatible data and dtype" + msg = "does not support reduction" with pytest.raises(TypeError, match=msg): df.agg("sum") @@ -1292,7 +1292,7 @@ def test_nuiscance_columns(): tm.assert_series_equal(result, expected) # TODO: GH#49399 will fix error message - msg = "DataFrame constructor called with" + msg = "does not support reduction" with pytest.raises(TypeError, match=msg): df.agg(["sum"]) From 890bdab35dc386507fb6a51e17589e66b6fb487f Mon Sep 17 00:00:00 2001 From: DG Date: Thu, 1 Dec 2022 07:28:17 +0530 Subject: [PATCH 2/2] Remove To Do messages --- pandas/tests/apply/test_frame_apply.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/tests/apply/test_frame_apply.py b/pandas/tests/apply/test_frame_apply.py index 0b857dc371e9d..7bf1621d0acea 100644 --- a/pandas/tests/apply/test_frame_apply.py +++ b/pandas/tests/apply/test_frame_apply.py @@ -1181,7 +1181,6 @@ def test_agg_multiple_mixed_raises(): ) # sorted index - # TODO: GH#49399 will fix error message msg = "does not support reduction" with pytest.raises(TypeError, match=msg): mdf.agg(["min", "sum"]) @@ -1291,7 +1290,6 @@ def test_nuiscance_columns(): expected = Series([6, 6.0, "foobarbaz"], index=["A", "B", "C"]) tm.assert_series_equal(result, expected) - # TODO: GH#49399 will fix error message msg = "does not support reduction" with pytest.raises(TypeError, match=msg): df.agg(["sum"])