There was an error while loading. Please reload this page.
1 parent 432ffba commit 519fa10Copy full SHA for 519fa10
pandas/tests/groupby/test_apply.py
@@ -1334,8 +1334,10 @@ def test_result_name_when_one_group(name):
1334
1335
1336
def test_empty_df():
1337
- empty_df = pd.DataFrame({"a": [], "b": []})
+ empty_df = DataFrame({"a": [], "b": []})
1338
+
1339
+ # Both operations should return an empty series instead of IndexError for apply UDF
1340
result = empty_df.groupby("a").b.apply(lambda x: x.values[-1])
- expected = empty_df.groupby("a").b.take([0])
1341
+ expected = empty_df.groupby("a").b.agg("sum")
1342
1343
tm.assert_series_equal(result, expected)
0 commit comments