Skip to content

REF: check instead of catching TypeError #29587

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

Merged
merged 2 commits into from
Nov 14, 2019
Merged
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
4 changes: 2 additions & 2 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,9 @@ def _aggregate_multiple_funcs(self, arg, _level, _axis):
if not len(results):
raise ValueError("no results")

try:
if all(np.ndim(x) > 0 for x in results):
return concat(results, keys=keys, axis=1, sort=False)
except TypeError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's an example that now ran into this TypeError?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's an example that now ran into this TypeError?

results = [3, 2, 1.5]; keys = ['size', 'count', 'mean']

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant the original dataframe / groupby example or test case that gives those values at this location

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identifying some relevant cases with an assert False, the place to look is in tests.frame.test_apply, e.g. test_non_callable_aggregates

else:

# we are concatting non-NDFrame objects,
# e.g. a list of scalars
Expand Down