def vector_stats(data, group=False): stats = pd.DataFrame() stats['name'] = data.name stats['run'] = data.run stats['mean'] = data.value.apply(lambda x: x.mean()) stats['max'] = data.value.apply(lambda x: x.max()) stats['min'] = data.value.apply(lambda x: x.min()) stats['std'] = data.value.apply(lambda x: x.std()) stats['count'] = data.value.apply(lambda x: x.size) return stats.groupby(['name']).mean().drop('run', axis=1) if group else stats
def merge_dates(stats): pat = '(^\d+\-\d+\-\d+)' extracted = stats.columns.str.extract(pat, expand=False) grouped = stats.groupby(extracted, axis=1).sum() return grouped
def merge_excercises(stats): pat = '(^student$|\d+$)' extracted = stats.columns.str.extract(pat, expand=False) grouped = stats.groupby(extracted, axis=1).sum() grouped = grouped.groupby(['student'], axis=0).sum() return grouped
def merge_excercises(stats): pat = '(\d+$)' extracted = stats.columns.str.extract(pat, expand=False) grouped = stats.groupby(extracted, axis=1).sum() return grouped