diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index 3f4273648b4d2..7f2c237c8b296 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -1747,7 +1747,7 @@ def _default_formatter(x: Any, precision: int, thousands: bool = False) -> Any: if is_float(x) or is_complex(x): return f"{x:,.{precision}f}" if thousands else f"{x:.{precision}f}" elif is_integer(x): - return f"{x:,.0f}" if thousands else str(x) + return f"{x:,}" if thousands else str(x) return x diff --git a/pandas/tests/io/formats/data/html/gh52272_expected_output.html b/pandas/tests/io/formats/data/html/gh52272_expected_output.html deleted file mode 100644 index 2c856be2a4e08..0000000000000 --- a/pandas/tests/io/formats/data/html/gh52272_expected_output.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - -
test
01234567890123456789
\ No newline at end of file diff --git a/pandas/tests/io/formats/style/test_format.py b/pandas/tests/io/formats/style/test_format.py index c6e981c684044..1c84816ead140 100644 --- a/pandas/tests/io/formats/style/test_format.py +++ b/pandas/tests/io/formats/style/test_format.py @@ -416,6 +416,17 @@ def test_str_escape_error(): _str_escape(2.00, "bad_escape") # OK since dtype is float +def test_long_int_formatting(): + df = DataFrame(data=[[1234567890123456789]], columns=["test"]) + styler = df.style + ctx = styler._translate(True, True) + assert ctx["body"][0][1]["display_value"] == "1234567890123456789" + + styler = df.style.format(thousands="_") + ctx = styler._translate(True, True) + assert ctx["body"][0][1]["display_value"] == "1_234_567_890_123_456_789" + + def test_format_options(): df = DataFrame({"int": [2000, 1], "float": [1.009, None], "str": ["&<", "&~"]}) ctx = df.style._translate(True, True) diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py index bf6148063877a..a66858d3f983e 100644 --- a/pandas/tests/io/formats/test_to_html.py +++ b/pandas/tests/io/formats/test_to_html.py @@ -896,11 +896,3 @@ def test_to_html_float_format_object_col(datapath): result = df.to_html(float_format=lambda x: f"{x:,.0f}") expected = expected_html(datapath, "gh40024_expected_output") assert result == expected - - -def test_to_html_float_point_double(datapath): - # GH#52272 - df = DataFrame(data=[[1234567890123456789]], columns=["test"]) - result = df.to_html() - expected = expected_html(datapath, "gh52272_expected_output") - assert result == expected diff --git a/pandas/tests/io/formats/test_to_latex.py b/pandas/tests/io/formats/test_to_latex.py index 64c064172a646..927bb8abc5e31 100644 --- a/pandas/tests/io/formats/test_to_latex.py +++ b/pandas/tests/io/formats/test_to_latex.py @@ -1407,16 +1407,3 @@ def test_to_latex_multiindex_multirow(self): """ ) assert result == expected - - -def test_to_latex_exceeding_float_point_double(): - df = DataFrame(data=[[1234567890123456789]], columns=["test"]) - expected = _dedent( - r""" - \begin{tabular}{lr} - & test \\ - 0 & 1234567890123456789 \\ - \end{tabular} - """ - ) - assert df.style.to_latex() == expected