Skip to content

Commit

Permalink
BUG: unicode repr handling fix for Python 3 re #1292, #1279
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed May 23, 2012
1 parent 0f4f99a commit 8f7caa5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pandas/core/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def to_string(self):
result = ['%s %s'] * len(fmt_values)
for i, (k, v) in enumerate(izip(fmt_index[1:], fmt_values)):
try:
idx = k.ljust(pad_space + (len(k) - len(k.decode('utf-8'))))
idx = k.ljust(pad_space + _encode_diff(k))
except UnicodeEncodeError:
idx = k.ljust(pad_space)
result[i] = result[i] % (idx, v)
Expand All @@ -130,6 +130,11 @@ def to_string(self):

return '\n'.join(result)

if py3compat.PY3: # pragma: no cover
_encode_diff = lambda x: 0
else:
def _encode_diff(x):
return len(x) - len(x.decode('utf-8'))

class DataFrameFormatter(object):
"""
Expand Down

0 comments on commit 8f7caa5

Please sign in to comment.