Skip to content

Commit

Permalink
ENH: Warn when to_datetime falls back to dateutil when dayfirst is pa…
Browse files Browse the repository at this point in the history
…ssed
  • Loading branch information
Aloqeely committed Jun 1, 2024
1 parent b162331 commit e90bb56
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ def _guess_datetime_format_for_array(arr, dayfirst: bool | None = False) -> str
return guessed_format
# If there are multiple non-null elements, warn about
# how parsing might not be consistent
if tslib.first_non_null(arr[first_non_null + 1 :]) != -1:
if dayfirst or tslib.first_non_null(arr[first_non_null + 1 :]) != -1:
warnings.warn(
"Could not infer format, so each element will be parsed "
"individually, falling back to `dateutil`. To ensure parsing is "
"individually, falling back to `dateutil` which does not take the "
"dayfirst parameter in consideration. To ensure parsing is "
"consistent and as-expected, please specify a format.",
UserWarning,
stacklevel=find_stack_level(),
Expand Down

0 comments on commit e90bb56

Please sign in to comment.