Skip to content

Commit

Permalink
ENH: make eng formatter a bit prettier for all accuracy values
Browse files Browse the repository at this point in the history
  • Loading branch information
lodagro authored and wesm committed Jan 11, 2012
1 parent 0d8a706 commit 188d828
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,11 @@ def __call__(self, num):
representing the power of 1000 of the original number. Some examples:
>>> format_eng(0) # for self.accuracy = 0
'0'
' 0'
>>> format_eng(1000000) # for self.accuracy = 1,
# self.use_eng_prefix = True
'1.0M'
' 1.0M'
>>> format_eng("-1e-6") # for self.accuracy = 2
# self.use_eng_prefix = False
Expand Down Expand Up @@ -481,10 +481,8 @@ def __call__(self, num):
mant = sign*dnum/(10**pow10)

if self.accuracy is None: # pragma: no cover
format_str = u"%g%s"
elif self.accuracy == 0:
format_str = u"%i%s"
elif self.accuracy > 0:
format_str = u"% g%s"
else:
format_str = (u"%% .%if%%s" % self.accuracy )

formatted = format_str % (mant, prefix)
Expand Down

0 comments on commit 188d828

Please sign in to comment.