17 lines
613 B
Python
17 lines
613 B
Python
"""Toy analytics harness using pandas.
|
|
|
|
compute_progress_frame takes a list of module instances and returns a
|
|
pandas.DataFrame summarizing progress per learner/module.
|
|
"""
|
|
from typing import List, Dict, Any
|
|
import pandas as pd
|
|
|
|
|
|
def compute_progress_frame(instances: List[Dict[str, Any]]) -> pd.DataFrame:
|
|
# instances: list of dicts { learner_id, module_id, progress }
|
|
df = pd.DataFrame(instances)
|
|
if df.empty:
|
|
return pd.DataFrame(columns=["learner_id", "module_id", "progress"])
|
|
grouped = df.groupby(["learner_id", "module_id"]).agg({"progress": "mean"}).reset_index()
|
|
return grouped
|