posit-dev / great-tables

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

fix: missing values in `fmt_number` #317

Closed jrycw closed 5 months ago

jrycw commented 5 months ago

Fix #314.

At first, I attempted to address this issue by utilizing the check from fmt_scientific to verify x:

if is_na(self._tbl_data, x):
    return x

However, this caused a failure in tests/test_export.py::test_html_string_generated. Consequently, I opted to directly check whether x is None or not.

from great_tables import GT, exibble
import polars as pl

exibble_pl = pl.from_pandas(exibble)

GT(exibble_pl).fmt_number(columns="num")

image

codecov-commenter commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.46%. Comparing base (38033ce) to head (640ab52). Report is 3 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #317 +/- ## ======================================= Coverage 82.45% 82.46% ======================================= Files 41 41 Lines 4258 4260 +2 ======================================= + Hits 3511 3513 +2 Misses 747 747 ```

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

machow commented 5 months ago

shoot... thanks for looking into this. I looked at a diff of the snapshot, and it seems okay to use the same is_na() guard is this function, since it's behavior will match the others. Hope it's okay, I just added to this PR!

rich-iannone commented 5 months ago

Thank you @jrycw !