Skip to content

Commit 212aa1f

Browse files
author
y-p
committed
BUG: UnicodeDecodeError in SeriesFormatter when series name is unicode
1 parent 5a4a49d commit 212aa1f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pandas/core/format.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,15 @@ def _get_footer(self):
7878

7979
if footer and self.series.name:
8080
footer += ', '
81-
footer += ("Name: %s" % str(self.series.name)
82-
if self.series.name is not None else '')
81+
82+
if self.series.name and \
83+
not isinstance(self.series.name,basestring):
84+
series_name=str(self.series.name)
85+
else:
86+
series_name=self.series.name
87+
88+
footer += (("Name: %s" % series_name)
89+
if series_name is not None else '')
8390

8491
if self.length:
8592
if footer:

pandas/tests/test_format.py

+5
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,11 @@ def test_to_string_float_na_spacing(self):
694694
'4 NaN')
695695
self.assertEqual(result, expected)
696696

697+
def test_unicode_name_in_footer(self):
698+
s=Series([1,2],name=u'\u05e2\u05d1\u05e8\u05d9\u05ea')
699+
sf=fmt.SeriesFormatter(s,name=u'\u05e2\u05d1\u05e8\u05d9\u05ea')
700+
sf._get_footer() # should not raise exception
701+
697702
class TestEngFormatter(unittest.TestCase):
698703

699704
def test_eng_float_formatter(self):

0 commit comments

Comments
 (0)