posit-dev / great-tables

Make awesome display tables using Python.
https://posit-dev.github.io/great-tables/
MIT License
1.44k stars 50 forks source link

Spanners use 'id' as a label and not 'label'. #273

Closed aussetg closed 1 month ago

aussetg commented 2 months ago

Description

Spanners use 'id' as a label and not 'label', despite what the documentation says.

Reproducible example

import polars as pl
from great_tables import GT

(
    GT(
        pl.DataFrame({'a': range(5), 'b': range(5)}),
    )
    .tab_spanner(label='True Label', id='false_label', columns=['a', 'b'])
)

Expected result

A spanner called 'True Label'.

Development environment

jrycw commented 2 months ago

It appears that the issue originates from the following line: https://github.com/posit-dev/great-tables/blob/b4d102a3576583fe561fbf9728457c5dde0b6493/great_tables/_utils_render_html.py#L179-L181

Setting ids to False seems to resolve the issue. However, this change may have implications on subsequent logic, requiring further investigation by the team.