DataJack
DataJack

Reputation: 415

How to resolve Quarto version upgrade breaking panel-tabset and pandas.to_html() interaction (1.2->1.3)

Rendering the below code chunk with Quarto cli version 1.2 generates 3 tabs labeled a, b and c with a nicely rendered table in each tab. However when I upgrade to version 1.3 all the tables appear in tab a.

Is there a way I should be using panel-tabset differently in version 1.3? Or if this was hacky and never really supported are there any alternative ways quarto can display tabs. I can't find any good alternatives to what I have achieved here in their documentation?

---
title: "Untitled"
format: html
---

# Test doc

::: {.panel-tabset}
```{python}
# | output: asis
import pandas as pd
import random
from IPython.display import display, Markdown, Latex
df = pd.DataFrame({"group":["a"]*3 + ["b"]*3 + ["c"]*3,"value":[random.randint(1,10) for i in range(9)]})


for group in df["group"].drop_duplicates():

    display(Markdown(f"\n"))
    display(Markdown(f"## {group}\n"))
    display(Markdown(f"\n"))
    print(df[df["group"]==group].to_html())

```

:::

Upvotes: 1

Views: 426

Answers (1)

luifrancgom
luifrancgom

Reputation: 424

You can do the following and reduce the amount of modules imported so you will reduce the probability of having problems in the future:

---
title: "Untitled"
format: html
---

# Test doc

::: {.panel-tabset}

```{python}
#| output: asis
import pandas as pd
import random
df = pd.DataFrame({"group":["a"]*3 + ["b"]*3 + ["c"]*3,
                   "value":[random.randint(1,10) for i in range(9)]})

for group in df["group"].drop_duplicates():

    print(f"## {group}")
    print(df[df["group"]==group].to_html())
    print()
```
:::

The sources I used to find the answer where the following:

Upvotes: 0

Related Questions