-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
BUG: groupby resample different results with .agg() vs .mean() #37905
BUG: groupby resample different results with .agg() vs .mean() #37905
Conversation
Hello @jalmaguer! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-12-21 05:42:45 UTC |
some CI Checks errors |
@jreback I made some commits a few days ago since your last comments so I just wanted to bump this pull request so that it doesn't get lost and forgotten about. |
… condition instead
# pandas\core\groupby\grouper.py:348: error: Item "None" of | ||
# "Optional[Any]" has no attribute "take" [union-attr] | ||
ax = self._grouper.take(obj.index) # type: ignore[union-attr] | ||
# Sometimes self._grouper will have been resorted while |
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.
can you track down exactly how this happens, this is a real problem, somthing is keeping state and now we are undoing it. Your fix is pretty clean, but this makes reasoning very about this very hard.
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.
It’s very complicated and you have to dig through a stack trace that is 18 method calls deep to understand it but I believe it’s because self._grouper which is meant to be the TimeGrouper though in this case is actually just a sorted DatetimeIndex is always sorted and obj if you go up the stack trace you’ll see that it is coming from a SeriesGroupby._selected_obj which I’m guessing just doesn’t get sorted when it’s created. The case where self._grouper has not been resorted I believe only happens when the dates were already in order and don’t need to be resorted.
can you merge master (been lots of changes in groupby recently) |
@jreback Sure no problem. Just merged it. Looks like it should be good to go. |
@jreback Just bumping this so it doesn't get forgotten |
ok we had some patches which might have fixed this can u merge master (and also test if your added tests pass w/o the patch) |
@jreback Just merged master. Looks like my added tests do not pass without the patch. |
thanks @jalmaguer |
@meeseeksdev backport 1.2.x |
… with .agg() vs .mean()
…() vs .mean() (#38633) Co-authored-by: Jose <jalmague@gmail.com>
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff