File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -13883,6 +13883,32 @@ def _format_number_safe(value: int) -> str:
13883
13883
13884
13884
def _fmt_lg(value: int, locale: str) -> str:
13885
13885
return vals.fmt_number(value, n_sigfig=3, compact=True, locale=locale)[0]
13886
+ def _format_single_float_with_gt(
13887
+ value: float, decimals: int = 2, locale: str = "en", df_lib=None
13888
+ ) -> str:
13889
+ if df_lib is None:
13890
+ # Use library detection to select appropriate DataFrame library
13891
+ if _is_lib_present("polars"):
13892
+ import polars as pl
13893
+
13894
+ df_lib = pl
13895
+ elif _is_lib_present("pandas"):
13896
+ import pandas as pd
13897
+
13898
+ df_lib = pd
13899
+ else:
13900
+ raise ImportError("Neither Polars nor Pandas is available for formatting")
13901
+
13902
+ # Create a single-row, single-column DataFrame using the specified library
13903
+ df = df_lib.DataFrame({"value": [value]})
13904
+
13905
+ # Create GT object and format the column
13906
+ gt_obj = GT(df).fmt_number(columns="value", decimals=decimals, locale=locale)
13907
+
13908
+ # Extract the formatted value using _get_column_of_values
13909
+ formatted_values = _get_column_of_values(gt_obj, column_name="value", context="html")
13910
+
13911
+ return formatted_values[0] # Return the single formatted value
13886
13912
13887
13913
13888
13914
def _transform_passed_failed(
You can’t perform that action at this time.
0 commit comments