posit-dev / great-tables

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

Feat: add ability to express units in `.cols_label()` #380

Closed rich-iannone closed 4 days ago

rich-iannone commented 1 week ago

This PR enhances the .cols_label() method by allowing units (in a specialized units notation) to be combined with label text. The result of this is the ability to have a column label suitable for presentation that also has units information that relate to the figures below a column. The units notation text is set off from the regular label text with "{{" / "}}".

Here's a basic example for how this works:

import pandas as pd
from great_tables import GT

df = pd.DataFrame({"x": [1.234, 2.345], "y": [3.456, 4.567], "z": [5.678, 6.789]})

GT(df).cols_label(x="Area ({{m^2}})", y="Density ({{kg / m^3}})", z = "Zee")
codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 79.68750% with 13 lines in your changes missing coverage. Please review.

Project coverage is 86.44%. Comparing base (c4cbd94) to head (b0dd277).

Files Patch % Lines
great_tables/_helpers.py 80.00% 6 Missing :warning:
great_tables/_text.py 64.28% 5 Missing :warning:
great_tables/_gt_data.py 71.42% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #380 +/- ## ========================================== - Coverage 86.59% 86.44% -0.15% ========================================== Files 42 42 Lines 4616 4654 +38 ========================================== + Hits 3997 4023 +26 - Misses 619 631 +12 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

machow commented 5 days ago

~@rich-iannone I think this branch might have accidentally been merged directly into main~

edit: wait I am so wrong I was looking at the wrong branch 😭