Skip to content

Fixed code breakage for return_type = tuples for axis = 0 #39375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def wrap_results_for_axis(
return res

elif self.result_type is None and all(
isinstance(x, dict) for x in results.values()
isinstance(x, (dict, tuple)) for x in results.values()
):
# Our operation was a to_dict op e.g.
# test_apply_dict GH#8735, test_apply_reduce_to_dict GH#25196 #37544
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/apply/test_frame_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ def test_apply_funcs_over_empty(self, func):
expected = getattr(df, func)()
tm.assert_series_equal(result, expected)

def test_apply_return_type_none(self):
# GH 35518
df = DataFrame([["orig1", "orig2"], ["orig3", "orig4"]])
result = df.apply(func=lambda col: ("new1", "new2"))

expected = Series(data=[("new1", "new2"), ("new1", "new2")])
tm.assert_series_equal(result, expected)

def test_nunique_empty(self):
# GH 28213
df = DataFrame(columns=["a", "b", "c"])
Expand Down