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: Ensure to_datetime raises errors for out-of-bounds scalar inputs #60744

Closed
wants to merge 9 commits into from

Conversation

kosiew
Copy link

@kosiew kosiew commented Jan 21, 2025

@kosiew kosiew requested a review from MarcoGorelli as a code owner January 21, 2025 06:16
@kosiew kosiew changed the title Fix datetime BUG: Ensure to_datetime raises errors for out-of-bounds scalar inputs Jan 21, 2025
@@ -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:
Copy link
Author

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.

Copy link
Member

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

Copy link
Author

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.

Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Mar 10, 2025
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: scalar out of bounds input does not raise for to_datetime
2 participants