From ff5b29e440f36cc8ae4d415df876d4444f59d471 Mon Sep 17 00:00:00 2001 From: y-p Date: Mon, 27 Jan 2014 04:07:03 +0200 Subject: [PATCH 1/2] TST: HTMLFormatter does not die on unicode frame GH6098 --- pandas/tests/test_format.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/tests/test_format.py b/pandas/tests/test_format.py index 005abf25f6584..bf71f2e3b1431 100644 --- a/pandas/tests/test_format.py +++ b/pandas/tests/test_format.py @@ -719,6 +719,14 @@ def test_to_html_index_formatter(self): """ self.assertEquals(result, expected) + def test_to_html_regression_GH6098(self): + df = DataFrame({u('clé1'): [u('a'), u('a'), u('b'), u('b'), u('a')], + u('clé2'): [u('1er'), u('2ème'), u('1er'), u('2ème'), u('1er')], + 'données1': np.random.randn(5), + 'données2': np.random.randn(5)}) + # it works + df.pivot_table(rows=[u('clé1')], cols=[u('clé2')])._repr_html_() + def test_nonunicode_nonascii_alignment(self): df = DataFrame([["aa\xc3\xa4\xc3\xa4", 1], ["bbbb", 2]]) rep_str = df.to_string() From 3ff71da683111ed25c042efe475764c028151521 Mon Sep 17 00:00:00 2001 From: y-p Date: Mon, 27 Jan 2014 04:08:35 +0200 Subject: [PATCH 2/2] BUG: HTMLFormatter does not die on unicode frame GH6098 --- doc/source/release.rst | 1 + pandas/core/format.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index d96a2ef973955..aa7b701ee39a3 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -155,6 +155,7 @@ Bug Fixes - Regression in ``.get(None)`` indexing from 0.12 (:issue:`5652`) - Subtle ``iloc`` indexing bug, surfaced in (:issue:`6059`) - Bug with insert of strings into DatetimeIndex (:issue:`5818`) + - Fixed unicode bug in to_html/HTML repr (:issue:`6098`) pandas 0.13.0 ------------- diff --git a/pandas/core/format.py b/pandas/core/format.py index fce0ef6a27889..6c66fc53b1f66 100644 --- a/pandas/core/format.py +++ b/pandas/core/format.py @@ -767,7 +767,7 @@ def _column_header(): levels)): name = self.columns.names[lnum] row = [''] * (row_levels - 1) + ['' if name is None - else str(name)] + else com.pprint_thing(name)] tags = {} j = len(row)