@@ -896,3 +896,59 @@ def test_to_html_float_format_object_col(datapath):
896
896
result = df .to_html (float_format = lambda x : f"{ x :,.0f} " )
897
897
expected = expected_html (datapath , "gh40024_expected_output" )
898
898
assert result == expected
899
+
900
+
901
+ def test_to_html_multiindex_col_with_colspace ():
902
+ # GH#53885
903
+ df = DataFrame ([[1 , 2 ]])
904
+ df .columns = MultiIndex .from_tuples ([(1 , 1 ), (2 , 1 )])
905
+ result = df .to_html (col_space = 100 )
906
+ expected = (
907
+ '<table border="1" class="dataframe">\n '
908
+ " <thead>\n "
909
+ " <tr>\n "
910
+ ' <th style="min-width: 100px;"></th>\n '
911
+ ' <th style="min-width: 100px;">1</th>\n '
912
+ ' <th style="min-width: 100px;">2</th>\n '
913
+ " </tr>\n "
914
+ " <tr>\n "
915
+ ' <th style="min-width: 100px;"></th>\n '
916
+ ' <th style="min-width: 100px;">1</th>\n '
917
+ ' <th style="min-width: 100px;">1</th>\n '
918
+ " </tr>\n "
919
+ " </thead>\n "
920
+ " <tbody>\n "
921
+ " <tr>\n "
922
+ " <th>0</th>\n "
923
+ " <td>1</td>\n "
924
+ " <td>2</td>\n "
925
+ " </tr>\n "
926
+ " </tbody>\n "
927
+ "</table>"
928
+ )
929
+ assert result == expected
930
+
931
+
932
+ def test_to_html_tuple_col_with_colspace ():
933
+ # GH#53885
934
+ df = DataFrame ({("a" , "b" ): [1 ], "b" : [2 ]})
935
+ result = df .to_html (col_space = 100 )
936
+ expected = (
937
+ '<table border="1" class="dataframe">\n '
938
+ " <thead>\n "
939
+ ' <tr style="text-align: right;">\n '
940
+ ' <th style="min-width: 100px;"></th>\n '
941
+ ' <th style="min-width: 100px;">(a, b)</th>\n '
942
+ ' <th style="min-width: 100px;">b</th>\n '
943
+ " </tr>\n "
944
+ " </thead>\n "
945
+ " <tbody>\n "
946
+ " <tr>\n "
947
+ " <th>0</th>\n "
948
+ " <td>1</td>\n "
949
+ " <td>2</td>\n "
950
+ " </tr>\n "
951
+ " </tbody>\n "
952
+ "</table>"
953
+ )
954
+ assert result == expected
0 commit comments