x_unique = np.unique(x)
y_means = np.array([np.mean(y[x == u]) for u in x_unique])
y_stds = np.array([np.std(y[x == u]) for u in x_unique])
Performing grouped average and standard deviation with NumPy arrays