Skip to content

Commit 4c23931

Browse files
committed
Add _format_numbers_with_gt() util fn
1 parent 9470c31 commit 4c23931

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pointblank/validate.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13802,6 +13802,24 @@ def _transform_eval(
1380213802
return symbol_list
1380313803

1380413804

13805+
def _format_numbers_with_gt(
13806+
values: list[int], n_sigfig: int = 3, compact: bool = True, locale: str = "en"
13807+
) -> list[str]:
13808+
"""Format numbers using Great Tables GT object to avoid pandas dependency."""
13809+
import polars as pl
13810+
13811+
# Create a single-column DataFrame with all values
13812+
df = pl.DataFrame({"values": values})
13813+
13814+
# Create GT object and format the column
13815+
gt_obj = GT(df).fmt_number(columns="values", n_sigfig=n_sigfig, compact=compact, locale=locale)
13816+
13817+
# Extract the formatted values using _get_column_of_values
13818+
formatted_values = _get_column_of_values(gt_obj, column_name="values", context="html")
13819+
13820+
return formatted_values
13821+
13822+
1380513823
def _transform_test_units(
1380613824
test_units: list[int], interrogation_performed: bool, active: list[bool], locale: str
1380713825
) -> list[str]:

0 commit comments

Comments
 (0)