-
-
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: Ensure to_datetime raises errors for out-of-bounds scalar inputs #60744
base: main
Are you sure you want to change the base?
Conversation
pandas/core/tools/datetimes.py
Outdated
@@ -479,11 +479,20 @@ def _array_strptime_with_fallback( | |||
return Index(result, dtype=result.dtype, name=name) | |||
|
|||
|
|||
def _to_datetime_with_unit(arg, unit, name, utc: bool, errors: str) -> Index: | |||
def _to_datetime_with_unit(arg, unit, name, utc: bool, errors: str) -> DatetimeIndex: |
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.
Making the annotation -> DatetimeIndex reflects that reality more precisely and helps both developers and tooling (like mypy) be certain of the return type.
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.
If errors=="ignore"
we would get an Index[object]
back so this is correct
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.
Good point. Thanks for pointing this out.
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.