Skip to content

Commit 2eec4f7

Browse files
committed
Fixed code breakage for tuples for axis = 0
PEP error fixed Modified previous commit
1 parent 309cf3a commit 2eec4f7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/core/apply.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def wrap_results_for_axis(
482482
return res
483483

484484
elif self.result_type is None and all(
485-
isinstance(x, dict) for x in results.values()
485+
isinstance(x, (dict, tuple)) for x in results.values()
486486
):
487487
# Our operation was a to_dict op e.g.
488488
# test_apply_dict GH#8735, test_apply_reduce_to_dict GH#25196 #37544

pandas/tests/apply/test_frame_apply.py

+8
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ def test_apply_funcs_over_empty(self, func):
131131
expected = getattr(df, func)()
132132
tm.assert_series_equal(result, expected)
133133

134+
def test_apply_return_type_none(self):
135+
# GH 35518
136+
df = DataFrame([["orig1", "orig2"], ["orig3", "orig4"]])
137+
result = df.apply(func=lambda col: ("new1", "new2"))
138+
139+
expected = Series(data=[("new1", "new2"), ("new1", "new2")])
140+
tm.assert_series_equal(result, expected)
141+
134142
def test_nunique_empty(self):
135143
# GH 28213
136144
df = DataFrame(columns=["a", "b", "c"])

0 commit comments

Comments
 (0)