Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ I/O
- Bug in :meth:`DataFrame.to_stata` when writing :class:`DataFrame` and ``byteorder=`big```. (:issue:`58969`)
- Bug in :meth:`DataFrame.to_string` that raised ``StopIteration`` with nested DataFrames. (:issue:`16098`)
- Bug in :meth:`HDFStore.get` was failing to save data of dtype datetime64[s] correctly (:issue:`59004`)
- Bug in :meth:`HTMLFormatter._write_cell_` which ignored the spacing between strings. (:issue:`59876`)
- Bug in :meth:`read_csv` causing segmentation fault when ``encoding_errors`` is not a string. (:issue:`59059`)
- Bug in :meth:`read_csv` raising ``TypeError`` when ``index_col`` is specified and ``na_values`` is a dict containing the key ``None``. (:issue:`57547`)
- Bug in :meth:`read_csv` raising ``TypeError`` when ``nrows`` and ``iterator`` are specified without specifying a ``chunksize``. (:issue:`59079`)
Expand Down
2 changes: 2 additions & 0 deletions pandas/io/formats/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ def _write_cell(
esc = {}

rs = pprint_thing(s, escape_chars=esc).strip()
# replace spaces betweens strings with non-breaking spaces
rs = rs.replace(" ", "  ")

if self.render_links and is_url(rs):
rs_unescaped = pprint_thing(s, escape_chars={}).strip()
Expand Down
21 changes: 19 additions & 2 deletions pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,29 @@ def test_repr_min_rows(self):
(None, "{:.3f}", "None"),
("", "{:.2f}", ""),
(112345.6789, "{:6.3f}", "112345.679"),
("foo foo", None, "foo      foo"),
(" foo", None, "foo"),
(
"foo foo foo",
None,
"foo foo       foo",
), # odd no.of spaces
(
"foo foo foo",
None,
"foo foo    foo",
), # even no.of spaces
],
)
) # test float formatting and nbsp in strings
def test_repr_float_formatting_html_output(
self, data, format_option, expected_values
):
with option_context("display.float_format", format_option.format):
if format_option is not None:
with option_context("display.float_format", format_option.format):
df = DataFrame({"A": [data]})
html_output = df._repr_html_()
assert expected_values in html_output
else:
df = DataFrame({"A": [data]})
html_output = df._repr_html_()
assert expected_values in html_output
Expand Down