@@ -372,7 +372,7 @@ def set_printoptions(precision=None, column_space=None, max_rows=None,
372
372
Alter default behavior of DataFrame.toString
373
373
374
374
precision : int
375
- Floating point output precision
375
+ Floating point output precision (number of significant digits)
376
376
column_space : int
377
377
Default space for DataFrame columns, defaults to 12
378
378
max_rows : int
@@ -427,22 +427,22 @@ class EngFormatter(object):
427
427
24 : "Y"
428
428
}
429
429
430
- def __init__ (self , precision = None , use_eng_prefix = False ):
431
- self .precision = precision
430
+ def __init__ (self , accuracy = None , use_eng_prefix = False ):
431
+ self .accuracy = accuracy
432
432
self .use_eng_prefix = use_eng_prefix
433
433
434
434
def __call__ (self , num ):
435
435
""" Formats a number in engineering notation, appending a letter
436
436
representing the power of 1000 of the original number. Some examples:
437
437
438
- >>> format_eng(0) # for self.precision = 0
438
+ >>> format_eng(0) # for self.accuracy = 0
439
439
'0'
440
440
441
- >>> format_eng(1000000) # for self.precision = 1,
441
+ >>> format_eng(1000000) # for self.accuracy = 1,
442
442
# self.use_eng_prefix = True
443
443
'1.0M'
444
444
445
- >>> format_eng("-1e-6") # for self.precision = 2
445
+ >>> format_eng("-1e-6") # for self.accuracy = 2
446
446
# self.use_eng_prefix = False
447
447
'-1.00E-06'
448
448
@@ -480,27 +480,40 @@ def __call__(self, num):
480
480
481
481
mant = sign * dnum / (10 ** pow10 )
482
482
483
- if self .precision is None : # pragma: no cover
483
+ if self .accuracy is None : # pragma: no cover
484
484
format_str = u"%g%s"
485
- elif self .precision == 0 :
485
+ elif self .accuracy == 0 :
486
486
format_str = u"%i%s"
487
- elif self .precision > 0 :
488
- format_str = (u"%% .%if%%s" % self .precision )
487
+ elif self .accuracy > 0 :
488
+ format_str = (u"%% .%if%%s" % self .accuracy )
489
489
490
490
formatted = format_str % (mant , prefix )
491
491
492
492
return formatted #.strip()
493
493
494
- def set_eng_float_format (precision = 3 , use_eng_prefix = False ):
494
+ def set_eng_float_format (precision = None , accuracy = 3 , use_eng_prefix = False ):
495
495
"""
496
496
Alter default behavior on how float is formatted in DataFrame.
497
- Format float in engineering format.
497
+ Format float in engineering format. By accuracy, we mean the number of
498
+ decimal digits after the floating point.
498
499
499
500
See also EngFormatter.
500
501
"""
501
- global GlobalPrintConfig
502
- GlobalPrintConfig .float_format = EngFormatter (precision , use_eng_prefix )
503
- GlobalPrintConfig .column_space = max (12 , precision + 9 )
502
+ if precision is not None : # pragma: no cover
503
+ import warnings
504
+ warnings .warn ("'precision' parameter in set_eng_float_format is "
505
+ "being renamed to 'accuracy'" , FutureWarning )
506
+ accuracy = precision
507
+
508
+ global _float_format , _column_space
509
+ _float_format = EngFormatter (accuracy , use_eng_prefix )
510
+ _column_space = max (12 , accuracy + 9 )
511
+
512
+ _float_format = None
513
+ _column_space = 12
514
+ _precision = 4
515
+ _max_rows = 500
516
+ _max_columns = 0
504
517
505
518
def _stringify (col ):
506
519
# unicode workaround
0 commit comments