groupby & mean or stdev

PHOTO EMBED

Mon Oct 11 2021 11:31:49 GMT+0000 (Coordinated Universal Time)

Saved by @CaoimhedeFrein #python

1
df['avg_value'] = df.groupby("x").y.transform('mean')
2
df['avg_value'] = df.groupby("x").y.mean()
content_copyCOPY

1) makes new column with mean of y grouped by x 2) calcs the mean of y grouped by x