cat_values = input_grouping.values
cs = np.unique(cat_values)
cat_dists = {k: mat[cat_values == k] for k in cs}
cat_means = {k: np.mean(v, axis=0) for k, v in cat_dists.items()}
cat_means = pd.DataFrame.from_dict(cat_means)
cat_means.columns = ["Mean: %s" % e for e in cat_means.columns]
cat_stds = {k: np.std(v, axis=0) for k, v in cat_dists.items()}
cat_stds = pd.DataFrame.from_dict(cat_stds)
cat_stds.columns = ["Std: %s" % e for e in cat_stds.columns]
After Change
cat_values = input_grouping.values
cs = np.unique(cat_values)
cat_dists = {k: mat[cat_values == k] for k in cs}
cat_percentiles = []
for percentile in percentiles:
data = {k: np.percentile(v, percentile, axis=0)
for k, v in cat_dists.items()}
data = pd.DataFrame.from_dict(data)