Closed
Description
Code Sample, a copy-pastable example if possible
import pandas as pd
import pandas.util.testing as tm
df = pd.DataFrame(index = tm.makeMultiIndex())
print(df.to_html(col_space=100))
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th style="min-width: 100;"></th>
<th style="min-width: 100;"></th>
</tr>
</thead>
<tbody>
<tr>
<th rowspan="2" valign="top"style="min-width: 100;">foo</th>
<th style="min-width: 100;">1</th>
</tr>
<tr>
<th style="min-width: 100;">2</th>
</tr>
<tr>
<th rowspan="2" valign="top"style="min-width: 100;">bar</th>
<th style="min-width: 100;">1</th>
</tr>
<tr>
<th style="min-width: 100;">2</th>
</tr>
</tbody>
</table>
Problem description
The col_space
parameter expects an int..
pandas/pandas/io/formats/format.py
Lines 47 to 48 in cb89bc0
it should be either px of % for HTML but this raises an error if you try.
print(df.to_html(col_space='100px'))
gives TypeError: '>' not supported between instances of 'str' and 'int'
The <th style="min-width: 100;">
is also applied needlessly to the <th>
tags within <tbody>
Expected Output
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th style="min-width: 100px;"></th>
<th style="min-width: 100px;"></th>
</tr>
</thead>
<tbody>
<tr>
<th rowspan="2" valign="top">foo</th>
<th>1</th>
</tr>
<tr>
<th>2</th>
</tr>
<tr>
<th rowspan="2" valign="top">bar</th>
<th>1</th>
</tr>
<tr>
<th>2</th>
</tr>
</tbody>
</table>
Output of pd.show_versions()
[paste the output of pd.show_versions()
here below this line]