Skip to content

Commit 179dc14

Browse files
authored
WARN improve some warnings introduced in PDEP4 (#50529)
improve warnings Co-authored-by: MarcoGorelli <>
1 parent 5097302 commit 179dc14

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

pandas/_libs/tslibs/parsing.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,8 @@ cdef void _maybe_warn_about_dayfirst(format: str, bint dayfirst):
10051005
)
10061006
if (day_index < month_index) and not dayfirst:
10071007
warnings.warn(
1008-
f"Parsing dates in {format} format when dayfirst=False was specified. "
1008+
f"Parsing dates in {format} format when dayfirst=False (the default) "
1009+
"was specified. "
10091010
"Pass `dayfirst=True` or specify a format to silence this warning.",
10101011
UserWarning,
10111012
stacklevel=find_stack_level(),

pandas/core/tools/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def _guess_datetime_format_for_array(arr, dayfirst: bool | None = False) -> str
139139
return guessed_format
140140
warnings.warn(
141141
"Could not infer format, so each element will be parsed "
142-
"individually by `dateutil`. To ensure parsing is "
142+
"individually, falling back to `dateutil`. To ensure parsing is "
143143
"consistent and as-expected, please specify a format.",
144144
UserWarning,
145145
stacklevel=find_stack_level(),

pandas/tests/io/parser/test_parse_dates.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,7 @@ def test_parse_dot_separated_dates(all_parsers):
20522052
name="a",
20532053
)
20542054
warn = UserWarning
2055-
msg = "when dayfirst=False was specified"
2055+
msg = r"when dayfirst=False \(the default\) was specified"
20562056
result = parser.read_csv_check_warnings(
20572057
warn, msg, StringIO(data), parse_dates=True, index_col=0
20582058
)

pandas/tests/tslibs/test_parsing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ def test_guess_datetime_format_wrong_type_inputs(invalid_type_dt):
262262
def test_guess_datetime_format_no_padding(string, fmt, dayfirst, warning):
263263
# see gh-11142
264264
msg = (
265-
f"Parsing dates in {fmt} format when dayfirst=False was specified. "
265+
rf"Parsing dates in {fmt} format when dayfirst=False \(the default\) "
266+
"was specified. "
266267
"Pass `dayfirst=True` or specify a format to silence this warning."
267268
)
268269
with tm.assert_produces_warning(warning, match=msg):

0 commit comments

Comments
 (0)