Skip to content

Commit 2aaa22a

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

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-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) or isinstance(x, 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

+7
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ 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+
df = DataFrame([["orig1", "orig2"], ["orig3", "orig4"]])
136+
result = df.apply(func=lambda col: ("new1", "new2"))
137+
138+
expected = Series(data=[("new1", "new2"), ("new1", "new2")])
139+
tm.assert_series_equal(result, expected)
140+
134141
def test_nunique_empty(self):
135142
# GH 28213
136143
df = DataFrame(columns=["a", "b", "c"])

0 commit comments

Comments
 (0)