First commit of claude's rework in django + vanillajs fronted
This commit is contained in:
30
apps/tools/analyzer/stats.py
Normal file
30
apps/tools/analyzer/stats.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def compute_overall_stats(df: pd.DataFrame) -> dict:
|
||||
s = df["speed"]
|
||||
return {
|
||||
"min_speed": s.min(),
|
||||
"max_speed": s.max(),
|
||||
"mean_speed": s.mean(),
|
||||
"std_speed": s.std(ddof=1),
|
||||
"count": len(df),
|
||||
}
|
||||
|
||||
|
||||
def compute_group_stats(groups: list) -> list:
|
||||
result = []
|
||||
for i, g in enumerate(groups):
|
||||
s = g["speed"]
|
||||
std = s.std(ddof=1) if len(g) > 1 else None
|
||||
result.append({
|
||||
"group_index": i + 1,
|
||||
"count": len(g),
|
||||
"min_speed": s.min(),
|
||||
"max_speed": s.max(),
|
||||
"mean_speed": s.mean(),
|
||||
"std_speed": std,
|
||||
"time_start": g["time"].min().strftime("%H:%M:%S"),
|
||||
"time_end": g["time"].max().strftime("%H:%M:%S"),
|
||||
})
|
||||
return result
|
||||
Reference in New Issue
Block a user