posit-dev / great-tables

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

Unify `GT.cols_label()` and `GT.cols_width()` to accept both `cases` and `**kwargs` #452

Closed jrycw closed 2 months ago

jrycw commented 2 months ago

This PR unifies GT.cols_label() and GT.cols_width() to accept both cases and **kwargs.

Currently, these two functions have different parameter structures, which can be confusing and often requires consulting the documentation. I hope this change simplifies their usage :)

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.75%. Comparing base (fedac08) to head (95708a5).

Files with missing lines Patch % Lines
great_tables/_spanners.py 90.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #452 +/- ## ======================================= Coverage 86.75% 86.75% ======================================= Files 42 42 Lines 4702 4711 +9 ======================================= + Hits 4079 4087 +8 - Misses 623 624 +1 ```

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

machow commented 2 months ago

Thanks, this is great! I wonder if in the future, there might be some good uses of polars expressions inside cases, e.g.

cols_width({cs.starts_with("abc_"): "50px"})

Although maybe there's a more polars way to go from selector -> literal? 🤔