Skip to content

Commit e562979

Browse files
author
y-p
committed
CLN: remove some unicode hair from pre-pprint_thing days GH3360
PTF
1 parent f9eea30 commit e562979

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

pandas/core/format.py

+2-26
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,9 @@ def to_string(self):
139139
maxlen = max(len(x) for x in fmt_index)
140140
pad_space = min(maxlen, 60)
141141

142-
_encode_diff = _encode_diff_func()
143-
144142
result = ['%s %s'] * len(fmt_values)
145143
for i, (k, v) in enumerate(izip(fmt_index[1:], fmt_values)):
146-
try:
147-
idx = k.ljust(pad_space + _encode_diff(k))
148-
except UnicodeEncodeError:
149-
idx = k.ljust(pad_space)
144+
idx = k.ljust(pad_space)
150145
result[i] = result[i] % (idx, v)
151146

152147
if self.header and have_header:
@@ -158,21 +153,6 @@ def to_string(self):
158153

159154
return unicode(u'\n'.join(result))
160155

161-
162-
def _encode_diff_func():
163-
if py3compat.PY3: # pragma: no cover
164-
_encode_diff = lambda x: 0
165-
else:
166-
encoding = get_option("display.encoding")
167-
168-
def _encode_diff(x):
169-
if not isinstance(x,unicode):
170-
return len(x) - len(x.decode(encoding))
171-
return 0
172-
173-
return _encode_diff
174-
175-
176156
def _strlen_func():
177157
if py3compat.PY3: # pragma: no cover
178158
_strlen = len
@@ -1490,7 +1470,6 @@ def _make_fixed_width(strings, justify='right', minimum=None):
14901470
return strings
14911471

14921472
_strlen = _strlen_func()
1493-
_encode_diff = _encode_diff_func()
14941473

14951474
max_len = np.max([_strlen(x) for x in strings])
14961475

@@ -1507,10 +1486,7 @@ def _make_fixed_width(strings, justify='right', minimum=None):
15071486
justfunc = lambda self, x: self.rjust(x)
15081487

15091488
def just(x):
1510-
try:
1511-
eff_len = max_len + _encode_diff(x)
1512-
except UnicodeError:
1513-
eff_len = max_len
1489+
eff_len = max_len
15141490

15151491
if conf_max is not None:
15161492
if (conf_max > 3) & (_strlen(x) > max_len):

0 commit comments

Comments
 (0)