@@ -1066,14 +1066,10 @@ def test_to_html_regression_GH6098(self):
1066
1066
df .pivot_table (index = [u ('clé1' )], columns = [u ('clé2' )])._repr_html_ ()
1067
1067
1068
1068
def test_to_html_truncate (self ):
1069
- pytest .skip ("unreliable on travis" )
1070
1069
index = pd .DatetimeIndex (start = '20010101' , freq = 'D' , periods = 20 )
1071
1070
df = DataFrame (index = index , columns = range (20 ))
1072
- fmt .set_option ('display.max_rows' , 8 )
1073
- fmt .set_option ('display.max_columns' , 4 )
1074
- result = df ._repr_html_ ()
1071
+ result = df .to_html (max_rows = 8 , max_cols = 4 )
1075
1072
expected = '''\
1076
- <div{0}>
1077
1073
<table border="1" class="dataframe">
1078
1074
<thead>
1079
1075
<tr style="text-align: right;">
@@ -1159,23 +1155,15 @@ def test_to_html_truncate(self):
1159
1155
<td>NaN</td>
1160
1156
</tr>
1161
1157
</tbody>
1162
- </table>
1163
- <p>20 rows × 20 columns</p>
1164
- </div>''' .format (div_style )
1165
- if compat .PY2 :
1166
- expected = expected .decode ('utf-8' )
1158
+ </table>'''
1167
1159
assert result == expected
1168
1160
1169
1161
def test_to_html_truncate_multi_index (self ):
1170
- pytest .skip ("unreliable on travis" )
1171
1162
arrays = [['bar' , 'bar' , 'baz' , 'baz' , 'foo' , 'foo' , 'qux' , 'qux' ],
1172
1163
['one' , 'two' , 'one' , 'two' , 'one' , 'two' , 'one' , 'two' ]]
1173
1164
df = DataFrame (index = arrays , columns = arrays )
1174
- fmt .set_option ('display.max_rows' , 7 )
1175
- fmt .set_option ('display.max_columns' , 7 )
1176
- result = df ._repr_html_ ()
1165
+ result = df .to_html (max_rows = 7 , max_cols = 7 )
1177
1166
expected = '''\
1178
- <div{0}>
1179
1167
<table border="1" class="dataframe">
1180
1168
<thead>
1181
1169
<tr>
@@ -1276,24 +1264,16 @@ def test_to_html_truncate_multi_index(self):
1276
1264
<td>NaN</td>
1277
1265
</tr>
1278
1266
</tbody>
1279
- </table>
1280
- <p>8 rows × 8 columns</p>
1281
- </div>''' .format (div_style )
1282
- if compat .PY2 :
1283
- expected = expected .decode ('utf-8' )
1267
+ </table>'''
1284
1268
assert result == expected
1285
1269
1270
+ @pytest .mark .xfail (reason = 'GH22887 TypeError' , strict = True )
1286
1271
def test_to_html_truncate_multi_index_sparse_off (self ):
1287
- pytest .skip ("unreliable on travis" )
1288
1272
arrays = [['bar' , 'bar' , 'baz' , 'baz' , 'foo' , 'foo' , 'qux' , 'qux' ],
1289
1273
['one' , 'two' , 'one' , 'two' , 'one' , 'two' , 'one' , 'two' ]]
1290
1274
df = DataFrame (index = arrays , columns = arrays )
1291
- fmt .set_option ('display.max_rows' , 7 )
1292
- fmt .set_option ('display.max_columns' , 7 )
1293
- fmt .set_option ('display.multi_sparse' , False )
1294
- result = df ._repr_html_ ()
1275
+ result = df .to_html (max_rows = 7 , max_cols = 7 , sparsify = False )
1295
1276
expected = '''\
1296
- <div{0}>
1297
1277
<table border="1" class="dataframe">
1298
1278
<thead>
1299
1279
<tr>
@@ -1387,11 +1367,7 @@ def test_to_html_truncate_multi_index_sparse_off(self):
1387
1367
<td>NaN</td>
1388
1368
</tr>
1389
1369
</tbody>
1390
- </table>
1391
- <p>8 rows × 8 columns</p>
1392
- </div>''' .format (div_style )
1393
- if compat .PY2 :
1394
- expected = expected .decode ('utf-8' )
1370
+ </table>'''
1395
1371
assert result == expected
1396
1372
1397
1373
def test_to_html_border (self ):
0 commit comments