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..7bf1621d0acea 100644 --- a/pandas/tests/apply/test_frame_apply.py +++ b/pandas/tests/apply/test_frame_apply.py @@ -1181,8 +1181,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 +1282,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") @@ -1291,8 +1290,7 @@ 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 = "DataFrame constructor called with" + msg = "does not support reduction" with pytest.raises(TypeError, match=msg): df.agg(["sum"])