0

I was going through the documentation https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_html.html It says I can pass a list. My understanding is passing a list should set width for each column.

**col_space**: col_spacestr or int, list or dict of int or str, optional
The minimum width of each column in CSS length units. An int is assumed to be px units.

But it just passes the list to style

<tr style="text-align: right;">
  <th style="min-width: [200, 75, 75, 75, 75, 75, 75];"></th>
  <th style="min-width: [200, 75, 75, 75, 75, 75, 75];">filename</th>
  <th style="min-width: [200, 75, 75, 75, 75, 75, 75];">type</th>
  <th style="min-width: [200, 75, 75, 75, 75, 75, 75];">status</th>
  <th style="min-width: [200, 75, 75, 75, 75, 75, 75];">message</th>
  <th style="min-width: [200, 75, 75, 75, 75, 75, 75];">user</th>
  <th style="min-width: [200, 75, 75, 75, 75, 75, 75];">date</th>
</tr>
1
  • 1
    What pandas version are you using? It works for me as expected for version 1.2.4, e.g. df.to_html(col_space=range(len(df.columns))) Commented Nov 3, 2021 at 7:31

2 Answers 2

1

Read pandas df.to_html documentary. If your pandas version is below 0.25.0 it wont work. https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_html.html

Sign up to request clarification or add additional context in comments.

Comments

0

Upgrading pandas from 0.25.0 to 1.xx.x helped to resolve the problem.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.