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

DataTables warning with Quarto and Pandas Styler #317

Open
SvenKlaassen opened this issue Sep 9, 2024 · 5 comments · May be fixed by #318
Open

DataTables warning with Quarto and Pandas Styler #317

SvenKlaassen opened this issue Sep 9, 2024 · 5 comments · May be fixed by #318

Comments

@SvenKlaassen
Copy link

When using pandas style with quarto, the html files display the following DataTables warning.

DataTables warning: Non-table node initialisation (DIV). For more information about this error, please see https://datatables.net/tn/2

A minimal example is

quarto --version
1.5.57
itables v2.1.5
---
title: "iTables with Caption and Pandas Styler"
format: html
---

```{python}
import numpy as np
import pandas as pd
from itables import init_notebook_mode

from itables.version import __version__

print(f"This is itables v{__version__}")
init_notebook_mode(all_interactive=True)

x = np.linspace(0, np.pi, 21)
df = pd.DataFrame({"sin": np.sin(x), "cos": np.cos(x)}, index=pd.Index(x, name="alpha"))

s = df.style

s.format("{:.3f}").format_index("{:.3f}")

s.set_caption("A Pandas Styler object").set_table_styles(
    [{"selector": "caption", "props": "caption-side: bottom; font-size:1em;"}]
)

The warning does not occur if the caption is not set.

@mwouts mwouts linked a pull request Sep 9, 2024 that will close this issue
@mwouts
Copy link
Owner

mwouts commented Sep 9, 2024

Hi @SvenKlaassen , thank you for the precise and helpful bug report! I have been able to reproduce and fix the problem in my dev environment.

May I ask you to give it a try as well? See the instructions at #318 (comment). Thanks!

@SvenKlaassen
Copy link
Author

Thank you for the very fast reply @mwouts!
The fix also solves the issue for me.

@mwouts
Copy link
Owner

mwouts commented Sep 10, 2024

You're welcome! Actually I see that, while the change fixes the issue in Quarto, it introduces a very significant regression (e.g. itables stops working in all the other contexts!!). I'll have a look and keep you posted!

@mwouts
Copy link
Owner

mwouts commented Sep 22, 2024

I've updated the PR, can you let me know if it still works for you? Thanks!

@SvenKlaassen
Copy link
Author

I still works perfectly on the PR.
Thanks again for the very fast update!

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

Successfully merging a pull request may close this issue.

2 participants