Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataFrame with long column labels is not rendered correctly with the pydata theme #761

Closed
LuoXueling opened this issue Sep 2, 2023 · 1 comment

Comments

@LuoXueling
Copy link

Hi. I am new to nbsphinx and sphinx.

I have a problem if the cell output is a DataFrame with long column labels when using html_theme = "pydata_sphinx_theme", as shown below, column labels collide with each other. But everything looks fine when using sphinx_rtd_theme.

image

Here is a minimal example:

  1. Build the default sphinx project with sphinx-quickstart.

  2. In conf.py:

extensions = [
    "nbsphinx",
]

html_theme = "pydata_sphinx_theme"
  1. In the notebook:
import pandas as pd

df = pd.DataFrame({f"ABCDEFGHIJKLMNOPQRSTUVWXYZ_{i}": 0.123456789 for i in range(10)}, index=[0])
df

I am using sphinx==6.2.1, nbsphinx==0.9.2, and pydata_sphinx_theme==0.13.3.

@LuoXueling
Copy link
Author

It is a known issue in pydata and pandas. Sorry for the bothering.

If someone has the same problem, here is my solution:

Add a .css file in conf.py such as:

html_static_path = ["_static"]

html_css_files = [
    "pandas.css",
]

where pandas.css contains:

table {
  width: auto;
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant