Skip to content

ENH: Report how far off the formatting is #57667

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 2 commits into from
Feb 28, 2024
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/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@ def _value_with_fmt(
# xref https://support.microsoft.com/en-au/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
if len(val) > 32767:
warnings.warn(
"Cell contents too long, truncated to 32767 characters",
f"Cell contents too long ({len(val)}), "
"truncated to 32767 characters",
UserWarning,
stacklevel=find_stack_level(),
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ def test_to_excel_empty_frame(self, engine, tmp_excel):
def test_to_excel_raising_warning_when_cell_character_exceed_limit(self):
# GH#56954
df = DataFrame({"A": ["a" * 32768]})
msg = "Cell contents too long, truncated to 32767 characters"
msg = r"Cell contents too long \(32768\), truncated to 32767 characters"
with tm.assert_produces_warning(
UserWarning, match=msg, raise_on_extra_warnings=False
):
Expand Down