(n_clusters = 3, random_state = 42, gamma = 1 / 50).fit(x) return pd.Series(clustering.labels_ + 1, index = index) pandarallel.initialize(nb_workers=2, progress_bar=True) ex \ .groupby(['measurement_id', 'time', 'group']) \ .parallel_apply(lambda x: cluster(x['x'], x[...