Skip to content

Commit d6918c1

Browse files
authored
BUG: Avoid intercepting TypeError in DataFrame.agg (#49969)
* remove TypeError intercept in agg * Remove To Do messages
1 parent 2804681 commit d6918c1

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

pandas/core/apply.py

-6
Original file line numberDiff line numberDiff line change
@@ -663,12 +663,6 @@ def agg(self):
663663
result = None
664664
try:
665665
result = super().agg()
666-
except TypeError as err:
667-
exc = TypeError(
668-
"DataFrame constructor called with "
669-
f"incompatible data and dtype: {err}"
670-
)
671-
raise exc from err
672666
finally:
673667
self.obj = obj
674668
self.axis = axis

pandas/tests/apply/test_frame_apply.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,7 @@ def test_agg_multiple_mixed_raises():
11811181
)
11821182

11831183
# sorted index
1184-
# TODO: GH#49399 will fix error message
1185-
msg = "DataFrame constructor called with"
1184+
msg = "does not support reduction"
11861185
with pytest.raises(TypeError, match=msg):
11871186
mdf.agg(["min", "sum"])
11881187

@@ -1283,16 +1282,15 @@ def test_nuiscance_columns():
12831282
)
12841283
tm.assert_frame_equal(result, expected)
12851284

1286-
msg = "DataFrame constructor called with incompatible data and dtype"
1285+
msg = "does not support reduction"
12871286
with pytest.raises(TypeError, match=msg):
12881287
df.agg("sum")
12891288

12901289
result = df[["A", "B", "C"]].agg("sum")
12911290
expected = Series([6, 6.0, "foobarbaz"], index=["A", "B", "C"])
12921291
tm.assert_series_equal(result, expected)
12931292

1294-
# TODO: GH#49399 will fix error message
1295-
msg = "DataFrame constructor called with"
1293+
msg = "does not support reduction"
12961294
with pytest.raises(TypeError, match=msg):
12971295
df.agg(["sum"])
12981296

0 commit comments

Comments
 (0)