Skip to content
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: Fix Series.groupby raising OutOfBoundsDatetime with DatetimeIndex and month name #54306

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

yuanx749
Copy link
Contributor

@yuanx749 yuanx749 commented Jul 29, 2023

Fix the bug as discussed in #48509 @topper-123

Comment on lines 980 to -981
try:
return gpr is obj[gpr.name]
except (KeyError, IndexError, InvalidIndexError):
Copy link
Member

Choose a reason for hiding this comment

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

It seems like any error we hit here will want to be ignored; what are thoughts on just doing try: ... except Exception: return False?

cc @jbrockmendel @mroeschke

Copy link
Member

Choose a reason for hiding this comment

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

How would you get an arbitrary exception here? A couple years back we made a concerted effort to be more specific in what we caught

Copy link
Member

Choose a reason for hiding this comment

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

I think there are other issues caused by not being strict enough here e.g. #51818

Copy link
Member

@rhshadrach rhshadrach Jul 31, 2023

Choose a reason for hiding this comment

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

I don't think you can; what I'm thinking is that any exception that can possibly be hit here we want to ignore. I'm not certain that's true though.

Copy link
Member

Choose a reason for hiding this comment

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

I think the listed exceptions here are ones that make sense if gpr.name is not found in obj.columns. Any other exceptions mean Something Has Gone Wrong and we would want a bug report to be filed

@rhshadrach rhshadrach added the Bug label Jul 31, 2023
@mroeschke mroeschke added this to the 2.1 milestone Aug 1, 2023
@mroeschke mroeschke merged commit 2c1ec41 into pandas-dev:main Aug 1, 2023
40 checks passed
@mroeschke
Copy link
Member

Thanks @yuanx749

@yuanx749 yuanx749 deleted the series-groupby branch August 2, 2023 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: groupby() attempts to converts name of Series if name is a month and index is DateTime
4 participants