IMPORT LIBRARIES


In [ ]:
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
from scipy.cluster.hierarchy import dendrogram, linkage
%matplotlib inline

LOAD DATA

Read CSV


In [ ]:
states = pd.read_csv('~/Desktop/ClusterData.csv')
list(states.columns.values)

Save numerical data only


In [ ]:
st = states[states.columns[2:]]
st.index = states.ix[:,1]

CLUSTERING

Create Linkage Matrix


In [ ]:
Z = linkage(st, 'ward')

Plot Dendrogram of Clusters


In [ ]:
plt.figure(figsize = (25, 10))
plt.title('Cluster with All Searches and Personality')
plt.ylabel('distance')
dendrogram(
    Z,
    labels = st.index,
    leaf_rotation = 0.,
    leaf_font_size = 18.,
)
plt.show()

In [ ]: