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

feat: add `fmt_icon()` method #515

Open rich-iannone opened 2 days ago

rich-iannone commented 2 days ago

This PR adds the fmt_icon() method. It depends on Font Awesome icons available in the faicons library, so that is a new dependency. Whenever that package is updated, new icons from the FA free set will be available. Here's an example of the fmt_icon() method in use:

import pandas as pd
from great_tables import GT
animals_foods_df = pd.DataFrame(
    {
        "animals": ["hippo", "fish,spider", "mosquito,locust,frog", "dog,cat", "kiwi-bird"],
        "foods": ["bowl-rice", "egg,pizza-slice", "burger,lemon,cheese", "carrot,hotdog", "bacon"],
    }
)
(
    GT(animals_foods_df)
    .fmt_icon(
        columns=["animals", "foods"],
        height="4em"
    )
    .cols_align(
        align="center",
        columns=["animals", "foods"]
    )
)
image
codecov[bot] commented 2 days ago

Codecov Report

Attention: Patch coverage is 85.71429% with 7 lines in your changes missing coverage. Please review.

Project coverage is 89.08%. Comparing base (aa7d553) to head (0e9e9e6).

Files with missing lines Patch % Lines
great_tables/_formats.py 85.41% 7 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #515 +/- ## ========================================== - Coverage 89.11% 89.08% -0.04% ========================================== Files 44 44 Lines 5220 5269 +49 ========================================== + Hits 4652 4694 +42 - Misses 568 575 +7 ```

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


🚨 Try these New Features: