@@ -130,6 +130,40 @@ def test_set_properties_subset(self):
130130 expected = {(0 , 0 ): ['color: white' ]}
131131 self .assertEqual (result , expected )
132132
133+ def test_index_name (self ):
134+ # https://github.com/pydata/pandas/issues/11655
135+ df = pd .DataFrame ({'A' : [1 , 2 ], 'B' : [3 , 4 ], 'C' : [5 , 6 ]})
136+ result = df .set_index ('A' ).style ._translate ()
137+
138+ expected = [[{'class' : 'blank' , 'type' : 'th' , 'value' : '' },
139+ {'class' : 'col_heading level0 col0' , 'type' : 'th' ,
140+ 'value' : 'B' },
141+ {'class' : 'col_heading level0 col1' , 'type' : 'th' ,
142+ 'value' : 'C' }],
143+ [{'class' : 'col_heading level2 col0' , 'type' : 'th' ,
144+ 'value' : 'A' },
145+ {'class' : 'blank' , 'type' : 'th' , 'value' : '' },
146+ {'class' : 'blank' , 'type' : 'th' , 'value' : '' }]]
147+
148+ self .assertEqual (result ['head' ], expected )
149+
150+ def test_multiindex_name (self ):
151+ # https://github.com/pydata/pandas/issues/11655
152+ df = pd .DataFrame ({'A' : [1 , 2 ], 'B' : [3 , 4 ], 'C' : [5 , 6 ]})
153+ result = df .set_index (['A' , 'B' ]).style ._translate ()
154+
155+ expected = [[{'class' : 'blank' , 'type' : 'th' , 'value' : '' },
156+ {'class' : 'blank' , 'type' : 'th' , 'value' : '' },
157+ {'class' : 'col_heading level0 col0' , 'type' : 'th' ,
158+ 'value' : 'C' }],
159+ [{'class' : 'col_heading level2 col0' , 'type' : 'th' ,
160+ 'value' : 'A' },
161+ {'class' : 'col_heading level2 col1' , 'type' : 'th' ,
162+ 'value' : 'B' },
163+ {'class' : 'blank' , 'type' : 'th' , 'value' : '' }]]
164+
165+ self .assertEqual (result ['head' ], expected )
166+
133167 def test_apply_axis (self ):
134168 df = pd .DataFrame ({'A' : [0 , 0 ], 'B' : [1 , 1 ]})
135169 f = lambda x : ['val: %s' % x .max () for v in x ]
0 commit comments