@@ -190,7 +190,8 @@ def test_to_html_unicode(self):
190
190
df .to_html ()
191
191
192
192
def test_to_html_multiindex_sparsify (self ):
193
- index = pd .MultiIndex .from_arrays ([[0 , 0 , 1 , 1 ], [0 , 1 , 0 , 1 ]])
193
+ index = pd .MultiIndex .from_arrays ([[0 , 0 , 1 , 1 ], [0 , 1 , 0 , 1 ]],
194
+ names = ['foo' , None ])
194
195
195
196
df = DataFrame ([[0 , 1 ], [2 , 3 ], [4 , 5 ], [6 , 7 ]], index = index )
196
197
@@ -203,6 +204,12 @@ def test_to_html_multiindex_sparsify(self):
203
204
<th>0</th>
204
205
<th>1</th>
205
206
</tr>
207
+ <tr>
208
+ <th>foo</th>
209
+ <th></th>
210
+ <th></th>
211
+ <th></th>
212
+ </tr>
206
213
</thead>
207
214
<tbody>
208
215
<tr>
@@ -514,28 +521,24 @@ def test_to_html_columns_arg(self):
514
521
self .assert_ ('<th>B</th>' not in result )
515
522
516
523
def test_to_html_multiindex (self ):
517
- columns = pandas .MultiIndex .from_tuples (zip (range ( 4 ),
524
+ columns = pandas .MultiIndex .from_tuples (zip (np . arange ( 2 ). repeat ( 2 ),
518
525
np .mod (range (4 ), 2 )),
519
526
names = ['CL0' , 'CL1' ])
520
527
df = pandas .DataFrame ([list ('abcd' ), list ('efgh' )], columns = columns )
521
528
result = df .to_html (justify = 'left' )
522
529
expected = ('<table border="1" class="dataframe">\n '
523
530
' <thead>\n '
524
531
' <tr>\n '
525
- ' <th><table><tbody><tr><td>CL0</td></tr><tr>'
526
- '<td>CL1</td></tr></tbody></table></th>\n '
527
- ' <th><table align="left" style="text-align: left;">'
528
- '<tbody><tr><td>0</td></tr><tr><td>0</td></tr></tbody>'
529
- '</table></th>\n '
530
- ' <th><table align="left" style="text-align: left;">'
531
- '<tbody><tr><td>1</td></tr><tr><td>1</td></tr></tbody>'
532
- '</table></th>\n '
533
- ' <th><table align="left" style="text-align: left;">'
534
- '<tbody><tr><td>2</td></tr><tr><td>0</td></tr></tbody>'
535
- '</table></th>\n '
536
- ' <th><table align="left" style="text-align: left;">'
537
- '<tbody><tr><td>3</td></tr><tr><td>1</td></tr></tbody>'
538
- '</table></th>\n '
532
+ ' <th>CL0</th>\n '
533
+ ' <th colspan="2" halign="left">0</th>\n '
534
+ ' <th colspan="2" halign="left">1</th>\n '
535
+ ' </tr>\n '
536
+ ' <tr>\n '
537
+ ' <th>CL1</th>\n '
538
+ ' <th>0</th>\n '
539
+ ' <th>1</th>\n '
540
+ ' <th>0</th>\n '
541
+ ' <th>1</th>\n '
539
542
' </tr>\n '
540
543
' </thead>\n '
541
544
' <tbody>\n '
@@ -567,18 +570,17 @@ def test_to_html_multiindex(self):
567
570
' <thead>\n '
568
571
' <tr>\n '
569
572
' <th></th>\n '
570
- ' <th><table align="right" style="text-align:'
571
- ' right;"><tbody><tr><td>0</td></tr><tr><td>0</td></tr>'
572
- '</tbody></table></th>\n '
573
- ' <th><table align="right" style="text-align:'
574
- ' right;"><tbody><tr><td>1</td></tr><tr><td>1</td></tr>'
575
- '</tbody></table></th>\n '
576
- ' <th><table align="right" style="text-align:'
577
- ' right;"><tbody><tr><td>2</td></tr><tr><td>0</td></tr>'
578
- '</tbody></table></th>\n '
579
- ' <th><table align="right" style="text-align:'
580
- ' right;"><tbody><tr><td>3</td></tr><tr><td>1</td></tr>'
581
- '</tbody></table></th>\n '
573
+ ' <th>0</th>\n '
574
+ ' <th>1</th>\n '
575
+ ' <th>2</th>\n '
576
+ ' <th>3</th>\n '
577
+ ' </tr>\n '
578
+ ' <tr>\n '
579
+ ' <th></th>\n '
580
+ ' <th>0</th>\n '
581
+ ' <th>1</th>\n '
582
+ ' <th>0</th>\n '
583
+ ' <th>1</th>\n '
582
584
' </tr>\n '
583
585
' </thead>\n '
584
586
' <tbody>\n '
0 commit comments