Skip to content

Commit 188d828

Browse files
lodagrowesm
authored andcommitted
ENH: make eng formatter a bit prettier for all accuracy values
1 parent 0d8a706 commit 188d828

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pandas/core/common.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,11 @@ def __call__(self, num):
436436
representing the power of 1000 of the original number. Some examples:
437437
438438
>>> format_eng(0) # for self.accuracy = 0
439-
'0'
439+
' 0'
440440
441441
>>> format_eng(1000000) # for self.accuracy = 1,
442442
# self.use_eng_prefix = True
443-
'1.0M'
443+
' 1.0M'
444444
445445
>>> format_eng("-1e-6") # for self.accuracy = 2
446446
# self.use_eng_prefix = False
@@ -481,10 +481,8 @@ def __call__(self, num):
481481
mant = sign*dnum/(10**pow10)
482482

483483
if self.accuracy is None: # pragma: no cover
484-
format_str = u"%g%s"
485-
elif self.accuracy == 0:
486-
format_str = u"%i%s"
487-
elif self.accuracy > 0:
484+
format_str = u"% g%s"
485+
else:
488486
format_str = (u"%% .%if%%s" % self.accuracy )
489487

490488
formatted = format_str % (mant, prefix)

0 commit comments

Comments
 (0)