text_plain_output_1.png
from sklearn.cluster import KMeans

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

df = pd.read_excel('/kaggle/input/social-profile-of-customers/Social profile of customers_without header.xlsx')

df.columns = [c.replace(' ', '_') for c in df.columns]

df.drop(columns=['Name_', 'Profile', 'Profession_', 'Location', 'Prority__level_1', 'Priority_level_2', 'Priority_level_3'], inplace=True)

df['Type_of_Location_'][0] = 1
df['Type_of_Location_'] = pd.to_numeric(df['Type_of_Location_'])

from sklearn.cluster import KMeans
k_means = KMeans(n_clusters=3).fit(df)
df1 = pd.read_excel('/kaggle/input/social-profile-of-customers/Social profile of customers_without header.xlsx')
clustering = pd.DataFrame({'Name': df1['Name '], 'Clusters': k_means.labels_})
clustering.to_csv('/kaggle/working/clustering_output.csv', index=False)
cl = pd.read_csv('/kaggle/working/clustering_output.csv')
cl.head()