Skip to content

Commit bb70d6e

Browse files
committed
implement changes post review
1 parent c619b3c commit bb70d6e

File tree

3 files changed

+23
-34
lines changed

3 files changed

+23
-34
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,7 @@ I/O
620620
^^^
621621
- Bug in :class:`DataFrame` and :class:`Series` ``repr`` of :py:class:`collections.abc.Mapping`` elements. (:issue:`57915`)
622622
- Bug in :meth:`.DataFrame.to_json` when ``"index"`` was a value in the :attr:`DataFrame.column` and :attr:`Index.name` was ``None``. Now, this will fail with a ``ValueError`` (:issue:`58925`)
623-
- Bug in :meth:`DataFrame._repr_html_` pass :func: ``get_option("display.float_format")`` to :class:`DataFrameFormatter`, such that HTML output respects the configured float formatting. (:issue:`59876`)
624-
- Bug in :meth:`DataFrame._repr_html_` pass :func:`get_option("display.float_format")` to :class:`DataFrameFormatter`, such that HTML output respects the configured float formatting (:issue:`59876`)
623+
- Bug in :meth:`DataFrame._repr_html_` which ignored the ``"display.float_format"`` option (:issue:`59876`)
625624
- Bug in :meth:`DataFrame.from_records` where ``columns`` parameter with numpy structured array was not reordering and filtering out the columns (:issue:`59717`)
626625
- Bug in :meth:`DataFrame.to_dict` raises unnecessary ``UserWarning`` when columns are not unique and ``orient='tight'``. (:issue:`58281`)
627626
- Bug in :meth:`DataFrame.to_excel` when writing empty :class:`DataFrame` with :class:`MultiIndex` on both axes (:issue:`57696`)

pandas/tests/io/formats/test_format.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
option_context,
2727
read_csv,
2828
reset_option,
29+
set_option,
2930
)
3031

3132
from pandas.io.formats import printing
@@ -368,6 +369,27 @@ def test_repr_min_rows(self):
368369
assert ".." not in repr(df)
369370
assert ".." not in df._repr_html_()
370371

372+
@pytest.mark.parametrize(
373+
"data, format_option, expected_values",
374+
[
375+
({"A": [12345.6789]}, "{:12.3f}", "12345.679"),
376+
({"A": [None]}, "{:.3f}", "None"),
377+
({"A": [""]}, "{:.2f}", ""),
378+
({"A": [112345.6789]}, "{:6.3f}", "112345.679"),
379+
],
380+
)
381+
def test_repr_float_formatting_html_output(self, data, format_option, expected_values):
382+
if format_option is not None:
383+
set_option("display.float_format", format_option.format)
384+
385+
df = DataFrame(data)
386+
html_output = df._repr_html_()
387+
assert expected_values in html_output
388+
389+
# reset option
390+
if format_option is not None:
391+
reset_option("display.float_format")
392+
371393
def test_str_max_colwidth(self):
372394
# GH 7856
373395
df = DataFrame(

pandas/tests/io/formats/test_info_repr_html.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)