Skip to content

WARN improve some warnings introduced in PDEP4 #50529

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

Merged
merged 1 commit into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,8 @@ cdef void _maybe_warn_about_dayfirst(format: str, bint dayfirst):
)
if (day_index < month_index) and not dayfirst:
warnings.warn(
f"Parsing dates in {format} format when dayfirst=False was specified. "
f"Parsing dates in {format} format when dayfirst=False (the default) "
"was specified. "
"Pass `dayfirst=True` or specify a format to silence this warning.",
UserWarning,
stacklevel=find_stack_level(),
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _guess_datetime_format_for_array(arr, dayfirst: bool | None = False) -> str
return guessed_format
warnings.warn(
"Could not infer format, so each element will be parsed "
"individually by `dateutil`. To ensure parsing is "
"individually, falling back to `dateutil`. To ensure parsing is "
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some pandas-paths are tried first, so it's not technically true that dateutil will always be used

"consistent and as-expected, please specify a format.",
UserWarning,
stacklevel=find_stack_level(),
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/parser/test_parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ def test_parse_dot_separated_dates(all_parsers):
name="a",
)
warn = UserWarning
msg = "when dayfirst=False was specified"
msg = r"when dayfirst=False \(the default\) was specified"
result = parser.read_csv_check_warnings(
warn, msg, StringIO(data), parse_dates=True, index_col=0
)
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/tslibs/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ def test_guess_datetime_format_wrong_type_inputs(invalid_type_dt):
def test_guess_datetime_format_no_padding(string, fmt, dayfirst, warning):
# see gh-11142
msg = (
f"Parsing dates in {fmt} format when dayfirst=False was specified. "
rf"Parsing dates in {fmt} format when dayfirst=False \(the default\) "
"was specified. "
"Pass `dayfirst=True` or specify a format to silence this warning."
)
with tm.assert_produces_warning(warning, match=msg):
Expand Down