Skip to content

Fix some pprint_thing warts #3038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from Apr 23, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions pandas/core/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,9 @@ def to_string(self):
maxlen = max(len(x) for x in fmt_index)
pad_space = min(maxlen, 60)

_encode_diff = _encode_diff_func()

result = ['%s %s'] * len(fmt_values)
for i, (k, v) in enumerate(izip(fmt_index[1:], fmt_values)):
try:
idx = k.ljust(pad_space + _encode_diff(k))
except UnicodeEncodeError:
idx = k.ljust(pad_space)
idx = k.ljust(pad_space)
result[i] = result[i] % (idx, v)

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

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


def _encode_diff_func():
if py3compat.PY3: # pragma: no cover
_encode_diff = lambda x: 0
else:
encoding = get_option("display.encoding")

def _encode_diff(x):
if not isinstance(x,unicode):
return len(x) - len(x.decode(encoding))
return 0

return _encode_diff


def _strlen_func():
if py3compat.PY3: # pragma: no cover
_strlen = len
Expand Down Expand Up @@ -1490,7 +1470,6 @@ def _make_fixed_width(strings, justify='right', minimum=None):
return strings

_strlen = _strlen_func()
_encode_diff = _encode_diff_func()

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

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

def just(x):
try:
eff_len = max_len + _encode_diff(x)
except UnicodeError:
eff_len = max_len
eff_len = max_len

if conf_max is not None:
if (conf_max > 3) & (_strlen(x) > max_len):
Expand Down