Coverage for mlprodict/cli/asv2csv.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief Command line about exporting :epkg:`asv` results into a dataframe.
4"""
5from datetime import datetime
6from ..asv_benchmark.asv_exports import enumerate_export_asv_json
9def asv2csv(folder, outfile=None, last_one=False, baseline=None,
10 conf=None, fLOG=print):
11 """
12 Converts results produced by :epkg:`asv` into :epkg:`csv`.
14 :param folder: folder where the results are
15 :param outfile: output the results into :epkg:`csv`
16 :param last_one: converts only the last report into csv
17 :param baseline: baseline usually ``'skl'``, if not empty,
18 computes ratios
19 :param conf: test configuration, to retrieve more metadata
20 :param fLOG: logging function
22 .. cmdref::
23 :title: Converts asv results into csv
24 :cmd: -m mlprodict asv2csv--help
25 :lid: l-cmd-asv2csv
27 The command converts :epkg:`asv` results into :epkg:`csv`.
29 Example::
31 python -m mlprodict asv2csv -f <folder> -o result.csv
33 The filename may contain ``<date>``, it is then replaced by
34 the time now.
35 """
36 iter_rows = enumerate_export_asv_json(
37 folder, last_one=last_one, baseline=baseline, conf=conf)
39 if outfile is None:
40 rows = []
41 for row in iter_rows:
42 fLOG(row)
43 rows.append(row)
44 return rows
46 import pandas
47 df = pandas.DataFrame(iter_rows)
48 outfile = outfile.replace(
49 "<date>",
50 datetime.now().strftime("%Y%m%dT%H%M%S"))
51 df.to_csv(outfile, index=False)
52 return df