Skip to content

Instantly share code, notes, and snippets.

@jinglescode
Last active March 7, 2020 08:48
Show Gist options
  • Save jinglescode/96ed281c7ec0500ec67a1a7d8f4c8c9e to your computer and use it in GitHub Desktop.
Save jinglescode/96ed281c7ec0500ec67a1a7d8f4c8c9e to your computer and use it in GitHub Desktop.
starting_point = 2 #@param {type:"integer"}
cur_index = starting_point
seq = [cur_index]
while len(seq) < len(list(df_distance_matrix.keys())):
nearest_clusters = list(df_distance_matrix[cur_index].sort_values().index)
for cluster_id in nearest_clusters:
if cluster_id != cur_index and cluster_id not in seq:
seq.append(cluster_id)
cur_index = cluster_id
break
replace_group_to_day = {}
for i in range(0, len(seq)):
replace_group_to_day[seq[i]] = i
print(' -> '.join(str(x) for x in seq))
places['days'] = places['cluster']
places['days'].replace(replace_group_to_day, inplace=True)
places['days'] += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment