quarto-dev / quarto-dev/quarto-cli
Default column alignment varies for Pandas dataframes and tables with captions
Open
Nobody has claimed this yet.
enhancement
tables
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
- Setup: I use
.ipynbdocuments in VS Code and quarto cli (v. 1.3.242) on Windows 10 to render the report to HTML. - Issue: I want to render Pandas tables with table captions. The column alignment is different when the index is included and excluded.
- Expected behaviour: the same defaults despite the fact that the index is included or excluded.
- Details.
HTML output:

The result in VS code – column alignment is the same in each case.

Code:
import pandas as pd
df = pd.DataFrame({
'Country': {0: 'Belgium', 1: 'England'},
'League': {0: 'Belgium Jupiler League', 1: 'England Premier League'}
})
#| label: tbl-1
#| tbl-cap: This column name alignment is expected.
df.style.hide(axis="index")
#| label: tbl-2
#| tbl-cap: Why are column labels aligned differently in this table compared
# to in the previous example?
df
File: ipynb file and rendered HTML output are attached
quarto_col_alignmet_bug.zip
Update
This might be related to .style accessor/attribute.
#| label: tbl-3
#| tbl-cap: It seams that `.style` changes the output.
df.style
- If this issue is not related to Quarto, can more examples of Quarto with Pandas and ipynb files be added?
Checklist
- Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- Please format your issue so it is easier for us to read the bug report.
- Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- Please document the operating system you're running. If on Linux, please provide the specific distribution.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.