Skip to content
Snippets Groups Projects
Commit 04809033 authored by Manon Blanco's avatar Manon Blanco Committed by Yoann Schneider
Browse files

Round mean values calculated during data analysis

parent aaeec5ed
No related branches found
No related tags found
1 merge request!288Round mean values calculated during data analysis
# -*- coding: utf-8 -*-
import logging
from collections import Counter, defaultdict
from functools import partial
from pathlib import Path
from typing import Dict, List, Optional
......@@ -32,23 +33,32 @@ def create_table(
operations = []
if count:
operations.append(("Count", len))
operations.append(("Count", len, None))
operations.extend(
[
("Min", np.min),
("Max", np.max),
("Mean", np.mean),
("Median", np.median),
("Min", np.min, None),
("Max", np.max, None),
("Mean", np.mean, 2),
("Median", np.median, 2),
]
)
if total:
operations.append(("Total", np.sum))
operations.append(("Total", np.sum, None))
statistics.add_rows(
[
[col_name, *list(map(operator, data.values()))]
for col_name, operator in operations
[
col_name,
*list(
map(
# Round values if needed
partial(round, ndigits=digits),
map(operator, data.values()),
)
),
]
for col_name, operator, digits in operations
]
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment