Skip to content

Commit e90bb56

Browse files
committed
ENH: Warn when to_datetime falls back to dateutil when dayfirst is passed
1 parent b162331 commit e90bb56

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pandas/core/tools/datetimes.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,11 @@ def _guess_datetime_format_for_array(arr, dayfirst: bool | None = False) -> str
135135
return guessed_format
136136
# If there are multiple non-null elements, warn about
137137
# how parsing might not be consistent
138-
if tslib.first_non_null(arr[first_non_null + 1 :]) != -1:
138+
if dayfirst or tslib.first_non_null(arr[first_non_null + 1 :]) != -1:
139139
warnings.warn(
140140
"Could not infer format, so each element will be parsed "
141-
"individually, falling back to `dateutil`. To ensure parsing is "
141+
"individually, falling back to `dateutil` which does not take the "
142+
"dayfirst parameter in consideration. To ensure parsing is "
142143
"consistent and as-expected, please specify a format.",
143144
UserWarning,
144145
stacklevel=find_stack_level(),

0 commit comments

Comments
 (0)