Skip to content

BUG: Raise on coercion of ambiguous datetime strings to datetime64 #61489

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iabhi4
Copy link
Contributor

@iabhi4 iabhi4 commented May 24, 2025

This PR addresses a bug where object-dtype arrays containing ambiguous datetime strings (e.g., "12/01/2020", "13/01/2020") were being silently coerced to datetime64[ns], potentially resulting in inconsistent or unintended parsing.

@iabhi4
Copy link
Contributor Author

iabhi4 commented May 24, 2025

The pre-commit is currently failing due to the unwanted-patterns-private-import-across-module hook

This PR imports _guess_datetime_format_for_array from pandas.core.tools.datetimes, which is a private function.
There’s currently no public alternative that offers this functionality. specifically, inferring a consistent datetime format from an array of strings without coercion.

Happy to refactor this if needed, for example, by moving it to a shared utility module or discussing exposing it publicly if that makes more sense long-term

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: inserting list of strings into Series auto-infers them as datetimes with mixed formats
1 participant