mwouts / itables

Pandas DataFrames as Interactive DataTables
https://mwouts.github.io/itables/
MIT License
761 stars 56 forks source link

Quarto #314

Open RegularnaMatrica opened 2 weeks ago

RegularnaMatrica commented 2 weeks ago

Hi, thank you for developing this package. I'm trying quarto for generating html reports. While using itables for displaying data.frames (show) I have encountered few problems:

  1. Using init_notebook_mode(all_interactive=True) does not render data.frames. Without it, it works. Is this expected? I thought its other way around.
  2. Above first data.frame in html I get: ::: {#cell-grouped missmatches .cell execution_count=4}. Did you maybe encounter this problem, or is due to my local setup?
  3. For each data.frame I get following warning: Unable to parse table from raw html block: skipping. I saw you opened issue, but it seemed this should be solved.
  4. When I try to use searchBuilder I get: SearchBuilder Requires DateTime when used with dates. When I remove timestamp column it works. Is it possible to specify which columns are targetable by searchBuilder?
mwouts commented 2 weeks ago

Hi @RegularnaMatrica, thanks for reaching out!

First thing can I ask which version of quarto and of itables you are using? For the later I would suggest adding this to your Quarto document:

from itables.version import __version__

print(f"This is itables v{__version__}")

Also there are two quarto examples in the documentation (https://mwouts.github.io/itables/quarto.html), and you might also find this example useful.

Now re your questions:

  1. Using init_notebook_mode(all_interactive=True) does not render data.frames. Without it, it works. Is this expected? I thought its other way around.

It should, cf. the examples in the documentation. Note that show might work without calling init_notebook_mode but I'd recommend to initialize itables nevertheless.

  1. Above first data.frame in html I get: ::: {#cell-grouped missmatches .cell execution_count=4}. Did you maybe encounter this problem, or is due to my local setup?

I am not aware of that problem, a minimal example would be welcome!

  1. For each data.frame I get following warning: Unable to parse table from raw html block: skipping. I saw you opened issue, but it seemed this should be solved.

Indeed that has been addressed in ITables 1.7.0, cf. the changelog, hence my question on ITables' version

  1. When I try to use searchBuilder I get: SearchBuilder Requires DateTime when used with dates.

That issue is a work in progress at https://github.com/mwouts/itables/issues/288, please help with the testing if you can.

When I remove timestamp column it works. Is it possible to specify which columns are targetable by searchBuilder?

Yes it is. Based on the datatables documentation https://datatables.net/reference/option/searchBuilder.columns you should be able to govern this through a "column" key (list of columns index) to the searchBuilder options (see also this PR: https://github.com/mwouts/itables/pull/242/files)

RegularnaMatrica commented 1 week ago

Thanks for the feedback and support.

itables version:

from itables.version import __version__
print(f"This is itables v{__version__}")
This is itables v2.1.4

quarto version:

quarto --version
1.5.57

import:

from itables import show, init_notebook_mode
import itables.options as opt

opt.showIndex = False
opt.lengthMenu = [5, 10, 20, 50]

init_notebook_mode(all_interactive=True)

From documentation: 'If you prefer to render only selected DataFrames as interactive tables, use itables.show to show ...'

so that is probably the reason why with init_notebook_mode(all_interactive=True) tables don't render because I'm using show function alongside it.

searchBuilder works by specifying column indices:

show(
    df, 
    layout = {"top1": "searchBuilder"},
    searchBuilder = {"columns": include_columns_indices}
)

Regarding ::: {#cell-grouped missmatches .cell execution_count=4 , it seems that chunk label is causing it (grouped missmatches was the label of the chunk):

---
title: "Test"
format:
  html:
    page-layout: full
    code-fold: true
jupyter: python3
---

```{python}
#| echo: false

from itables import show
import itables.options as opt
import pandas as pd

opt.showIndex = False
opt.lengthMenu = [5, 10, 20, 50]
#| label: group name
#| echo: false

df = pd.DataFrame({"A": [0]})

show(df)


It seems that message is rendered if there is label parameter with multiple words. If chunk label  `group name` is changed to `group_name` or label is removed, then its OK.