Skip to content

Commit 7eccc89

Browse files
committed
update benchmark test
1 parent 1983866 commit 7eccc89

File tree

2 files changed

+17
-29
lines changed

2 files changed

+17
-29
lines changed

asv_bench/benchmarks/io/csv.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ def setup(self, kind):
5252
def time_frame(self, kind):
5353
self.df.to_csv(self.fname)
5454

55+
class ToCSVFloatFormatVariants(BaseIO):
56+
fname = "__test__.csv"
57+
58+
def setup(self):
59+
self.df = DataFrame(np.random.default_rng(seed=42).random((1000, 1000)))
60+
61+
def time_old_style_percent_format(self):
62+
self.df.to_csv(self.fname, float_format="%.6f")
63+
64+
def time_new_style_brace_format(self):
65+
self.df.to_csv(self.fname, float_format="{:.6f}")
66+
67+
def time_new_style_thousands_format(self):
68+
self.df.to_csv(self.fname, float_format="{:,.2f}")
69+
70+
def time_callable_format(self):
71+
self.df.to_csv(self.fname, float_format=lambda x: f"{x:.6f}")
5572

5673
class ToCSVMultiIndexUnusedLevels(BaseIO):
5774
fname = "__test__.csv"

pandas/tests/io/formats/test_csv_benchmarks.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)