Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created May 5, 2021
Embed
What would you like to do?
df = data.copy()
scaler = StandardScaler()
x = scaler.fit_transform(df)
kmeans = KMeans(5)
kmeans.fit(x)
labels = kmeans.labels_
clusters = pd.concat([data, pd.DataFrame({"Cluster": labels})], axis=1)
print(clusters.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment