-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: aggregations were getting overwritten if they had the same name #30858
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
Changes from 7 commits
20049c1
ab685fd
e38e450
cb849a2
521bc1d
ec93c4f
6f9aac8
a8e9121
b857c6d
44d00df
523effb
552063a
5e2e7d2
40f7e31
f8f2d7f
dba7dde
1b43ed1
868a680
5d7f3db
14b2402
829dce8
3469f5d
862b39e
5e3f333
e7629f3
51158ef
447dfea
2693956
aa988a4
7a62f5f
d80ddc5
4f954d4
62d91d1
fb3ba5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,8 +311,8 @@ def _aggregate_multiple_funcs(self, arg): | |
|
||
arg = zip(columns, arg) | ||
|
||
results = {} | ||
for name, func in arg: | ||
results: Mapping[base.OutputKey, Union[Series, DataFrame]] = {} | ||
for idx, (name, func) in enumerate(arg): | ||
obj = self | ||
|
||
# reset the cache so that we | ||
|
@@ -321,13 +321,12 @@ def _aggregate_multiple_funcs(self, arg): | |
obj = copy.copy(obj) | ||
obj._reset_cache() | ||
obj._selection = name | ||
results[name] = obj.aggregate(func) | ||
results[base.OutputKey(label=name, position=idx)] = obj.aggregate(func) | ||
MarcoGorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if any(isinstance(x, DataFrame) for x in results.values()): | ||
# let higher level handle | ||
return results | ||
|
||
return DataFrame(results, columns=columns) | ||
return {key.label: value for key, value in results.items()} | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return DataFrame(self._wrap_aggregated_output(results), columns=columns) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the DataFrame constructor still required here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the test
when we get here we have
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WillAyd have updated with a call to |
||
|
||
def _wrap_series_output( | ||
self, output: Mapping[base.OutputKey, Union[Series, np.ndarray]], index: Index | ||
|
@@ -358,8 +357,10 @@ def _wrap_series_output( | |
if len(output) > 1: | ||
result = DataFrame(indexed_output, index=index) | ||
result.columns = columns | ||
else: | ||
elif not columns.empty: | ||
result = Series(indexed_output[0], index=index, name=columns[0]) | ||
else: | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
result = DataFrame() | ||
|
||
return result | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.