Skip to content

Commit 6ed863a

Browse files
author
y-p
committed
Merge pull request #6112 from y-p/PR_GH6098
BUG: HTMLFormatter does not die on unicode frame GH6098
2 parents da59b11 + 3ff71da commit 6ed863a

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

doc/source/release.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ Bug Fixes
155155
- Regression in ``.get(None)`` indexing from 0.12 (:issue:`5652`)
156156
- Subtle ``iloc`` indexing bug, surfaced in (:issue:`6059`)
157157
- Bug with insert of strings into DatetimeIndex (:issue:`5818`)
158+
- Fixed unicode bug in to_html/HTML repr (:issue:`6098`)
158159

159160
pandas 0.13.0
160161
-------------

pandas/core/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ def _column_header():
767767
levels)):
768768
name = self.columns.names[lnum]
769769
row = [''] * (row_levels - 1) + ['' if name is None
770-
else str(name)]
770+
else com.pprint_thing(name)]
771771

772772
tags = {}
773773
j = len(row)

pandas/tests/test_format.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,14 @@ def test_to_html_index_formatter(self):
719719
</table>"""
720720
self.assertEquals(result, expected)
721721

722+
def test_to_html_regression_GH6098(self):
723+
df = DataFrame({u('clé1'): [u('a'), u('a'), u('b'), u('b'), u('a')],
724+
u('clé2'): [u('1er'), u('2ème'), u('1er'), u('2ème'), u('1er')],
725+
'données1': np.random.randn(5),
726+
'données2': np.random.randn(5)})
727+
# it works
728+
df.pivot_table(rows=[u('clé1')], cols=[u('clé2')])._repr_html_()
729+
722730
def test_nonunicode_nonascii_alignment(self):
723731
df = DataFrame([["aa\xc3\xa4\xc3\xa4", 1], ["bbbb", 2]])
724732
rep_str = df.to_string()

0 commit comments

Comments
 (0)