From 6eee41cca2c4ca427b44a230ca1837642966e820 Mon Sep 17 00:00:00 2001 From: Franck Charras <29153872+fcharras@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:56:16 +0200 Subject: [PATCH] Limit the number of displayed number of significant numbers --- benchmarks/kmeans/consolidate_result_csv.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/benchmarks/kmeans/consolidate_result_csv.py b/benchmarks/kmeans/consolidate_result_csv.py index 0eb51ec..3de9f28 100644 --- a/benchmarks/kmeans/consolidate_result_csv.py +++ b/benchmarks/kmeans/consolidate_result_csv.py @@ -1,4 +1,5 @@ import hashlib +from functools import partial from io import BytesIO from itertools import zip_longest from operator import attrgetter @@ -348,7 +349,24 @@ def _sanitize_df_with_tocsv(df): def _df_to_csv(df, target): - df.to_csv(target, index=False, mode="a", date_format=DATES_FORMAT) + float_format_fn = partial( + np.format_float_positional, + precision=3, + unique=True, + fractional=False, + trim="-", + sign=False, + pad_left=None, + pad_right=None, + min_digits=None, + ) + df.to_csv( + target, + index=False, + mode="a", + float_format=float_format_fn, + date_format=DATES_FORMAT, + ) def _gspread_sync(source, gspread_url, gspread_auth_key):