@@ -149,12 +149,17 @@ class DataFrameFormatter(object):
149
149
150
150
def __init__ (self , frame , buf = None , columns = None , col_space = None ,
151
151
header = True , index = True , na_rep = 'NaN' , formatters = None ,
152
- justify = None , float_format = None , sparsify = True ,
152
+ justify = None , float_format = None , sparsify = None ,
153
153
index_names = True , ** kwds ):
154
154
self .frame = frame
155
155
self .buf = buf if buf is not None else StringIO ()
156
156
self .show_index_names = index_names
157
+
158
+ if sparsify is None :
159
+ sparsify = print_config .multi_sparse
160
+
157
161
self .sparsify = sparsify
162
+
158
163
self .float_format = float_format
159
164
self .formatters = formatters if formatters is not None else {}
160
165
self .na_rep = na_rep
@@ -662,7 +667,8 @@ def _has_names(index):
662
667
def set_printoptions (precision = None , column_space = None , max_rows = None ,
663
668
max_columns = None , colheader_justify = None ,
664
669
max_colwidth = None , notebook_repr_html = None ,
665
- date_dayfirst = None , date_yearfirst = None ):
670
+ date_dayfirst = None , date_yearfirst = None ,
671
+ multi_sparse = None ):
666
672
"""
667
673
Alter default behavior of DataFrame.toString
668
674
@@ -686,6 +692,9 @@ def set_printoptions(precision=None, column_space=None, max_rows=None,
686
692
When True, prints and parses dates with the day first, eg 20/01/2005
687
693
date_yearfirst : boolean
688
694
When True, prints and parses dates with the year first, eg 2005/01/20
695
+ multi_sparse : boolean
696
+ Default True, "sparsify" MultiIndex display (don't display repeated
697
+ elements in outer levels within groups)
689
698
"""
690
699
if precision is not None :
691
700
print_config .precision = precision
@@ -705,6 +714,8 @@ def set_printoptions(precision=None, column_space=None, max_rows=None,
705
714
print_config .date_dayfirst = date_dayfirst
706
715
if date_yearfirst is not None :
707
716
print_config .date_yearfirst = date_yearfirst
717
+ if multi_sparse is not None :
718
+ print_config .multi_sparse = multi_sparse
708
719
709
720
def reset_printoptions ():
710
721
print_config .reset ()
@@ -834,6 +845,7 @@ def __init__(self):
834
845
self .notebook_repr_html = True
835
846
self .date_dayfirst = False
836
847
self .date_yearfirst = False
848
+ self .multi_sparse = True
837
849
838
850
def reset (self ):
839
851
self .__init__ ()
0 commit comments