-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Prevent Unlimited Agg Recursion with Duplicate Col Names #21066
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
11703aa
ee78264
aa781ad
254af5f
88fbd09
2d4cf40
f0135e8
e88eb9b
4a24f73
c0dc3f4
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 |
---|---|---|
|
@@ -5731,7 +5731,12 @@ def diff(self, periods=1, axis=0): | |
# ---------------------------------------------------------------------- | ||
# Function application | ||
|
||
def _gotitem(self, key, ndim, subset=None): | ||
def _gotitem(self, | ||
key, # type: Union[str, List[str]] | ||
ndim, # type: int | ||
subset=None # type: Union[Series, DataFrame, None] | ||
): | ||
# type: (...) -> Union[Series, DataFrame] | ||
""" | ||
sub-classes to define | ||
return a sliced object | ||
|
@@ -5746,9 +5751,11 @@ def _gotitem(self, key, ndim, subset=None): | |
""" | ||
if subset is None: | ||
subset = self | ||
elif subset.ndim == 1: | ||
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 this line actually hit in tests? return self._constructor here doesn't make sense 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. Yes this is actually hit by the test case and code that was in place. A Series is a valid value for the subset parameter so I’m forcing it to a DataFrame or else the subsequent slice would fail. All for a better way if you think there’s one 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. what operation actually hits this code? 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. This line (which was changed to prevent the unlimited calls): This would pass a Series before (unless column names were duplicated), though it never raised an error because of the code in Definitely convoluted - I think it was inadvertent before the way 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. no the issue is why you are wrapping it with
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. Hmm you're probably right with that - I suppose could just return immediately if |
||
subset = self._constructor(subset) | ||
|
||
# TODO: _shallow_copy(subset)? | ||
return self[key] | ||
return subset[key] | ||
|
||
_agg_doc = dedent(""" | ||
The aggregation operations are always performed over an axis, either the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize we don't have an overall strategy for annotations just yet but I had to think through this as I was debugging anyway, so figured I'd put here explicitly for when we turn this on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok!