quarto-dev / quarto-dev/quarto-cli

Default column alignment varies for Pandas dataframes and tables with captions

Open
#4,627 0 comments 0 reactions 1 assignee View on GitHub

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 .ipynb documents 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:

image

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

image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.