Skip to content

Commit 94fbd78

Browse files
committed
BUG: handle zero-padding differently per comment in#578
1 parent 782bec3 commit 94fbd78

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

pandas/core/common.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def _try_sort(iterable):
360360
except Exception:
361361
return listed
362362

363-
def set_printoptions(precision=None, column_space=None, max_rows=None,
363+
def set_printoptions(precision=None, column_space=None, max_rows=None,
364364
max_columns=None):
365365
"""
366366
Alter default behavior of DataFrame.toString
@@ -523,7 +523,10 @@ def _just_help(x):
523523
# if we pass col_width, pad-zero the floats so all are same in column
524524
if col_width is not None and formatted != ' 0':
525525
padzeros = col_width - len(formatted)
526-
if padzeros > 0:
526+
if padzeros > 0 and 'e' in formatted:
527+
num, exp = formatted.split('e')
528+
formatted = "%s%se%s" % (num, ('0' * padzeros), exp)
529+
elif padzeros > 0:
527530
formatted = formatted + ('0' * padzeros)
528531

529532
return _just_help(formatted)

pandas/core/format.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ def _myformat(col):
203203
if issubclass(col.dtype.type, np.floating):
204204
col_width = max(map(len, map(formatter, col)))
205205
formatter = lambda v: _format(v, space=col_space,
206-
na_rep=self.na_rep,
207-
float_format=self.float_format,
208-
col_width=col_width)
206+
na_rep=self.na_rep,
207+
float_format=self.float_format,
208+
col_width=col_width)
209209
return formatter
210210

211211
formatters = {} if self.formatters is None else self.formatters

0 commit comments

Comments
 (0)