diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py index f69cac62513d4..845fb1ee3dc3a 100644 --- a/pandas/tests/io/formats/test_to_html.py +++ b/pandas/tests/io/formats/test_to_html.py @@ -1844,6 +1844,67 @@ def test_to_html_no_index_max_rows(self): """) assert result == expected + def test_to_html_multiindex_max_cols(self): + # GH 6131 + index = MultiIndex(levels=[['ba', 'bb', 'bc'], ['ca', 'cb', 'cc']], + labels=[[0, 1, 2], [0, 1, 2]], + names=['b', 'c']) + columns = MultiIndex(levels=[['d'], ['aa', 'ab', 'ac']], + labels=[[0, 0, 0], [0, 1, 2]], + names=[None, 'a']) + data = np.array( + [[1., np.nan, np.nan], [np.nan, 2., np.nan], [np.nan, np.nan, 3.]]) + df = DataFrame(data, index, columns) + result = df.to_html(max_cols=2) + expected = dedent("""\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
d
aaa...ac
bc
baca1.0...NaN
bbcbNaN...NaN
bcccNaN...3.0
""") + assert result == expected + def test_to_html_notebook_has_style(self): df = pd.DataFrame({"A": [1, 2, 3]}) result = df.to_html(notebook=True)