Skip to content

Instantly share code, notes, and snippets.

@nim4n136
Created March 19, 2020 16:37
Show Gist options
  • Save nim4n136/7a102c02759106a920a367a5567137f0 to your computer and use it in GitHub Desktop.
Save nim4n136/7a102c02759106a920a367a5567137f0 to your computer and use it in GitHub Desktop.
cluster.py
from collections import defaultdict
def cluster_data(lst_array, max_range):
clustered = defaultdict(list)
n = 1
for lst in lst_array:
clustered[n].append(lst)
n = n+1
if n > max_range:
n = 1
return clustered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment