title: Python: k-means clustering on multiple variables from a predetermined csv
body: <p>I'm working at a project for my thesis but I'm very sad because I can't do the k-means clustering on my dataset from Spotify API.</p>
  
  <blockquote>
    <p>artist_name   track_popularity    explicit    artist_genres   album_genres    acousticness    danceability    energy  instrumentalness    key     liveness    loudness    mode    speechness  tempo   time_signature  valence     played_at </p>
  </blockquote>
  
  <p>My dataset has these variables, I have to make clustering on the variables from acoustincness to valence (so 12 variables). How can I do this?
  I can do this with 2 or 3 variables, but I can't do it with four o more than four variables.</p>
  
  <pre><code>&gt; from copy import deepcopy
  import numpy as np
  import matplotlib.pyplot as plot
  import pandas as pd
  from sklearn.cluster import KMeans
  #importing Dataset
  dataset = pd.read_csv('csvProva2.csv')
  X = dataset.iloc[:, [10,11]].values #colonne che mi interessano
  
  #Find the number of clusters
  wcss = []
  
  for i in range (1,16): #15 cluster
      kmeans = KMeans(n_clusters = i, init='k-means++', random_state=0) 
      kmeans.fit(X)
      wcss.append(kmeans.inertia_)
  
  plot.plot(range(1,16),wcss)
  plot.title('Elbow Method')
  plot.xlabel('Number of clusters')
  plot.ylabel('wcss')
  plot.show()
  
  #KMeans clustering
  kmeans= KMeans(n_clusters=4,init='k-means++', random_state=0)
  y=kmeans.fit_predict(X)
  
  plot.scatter(X[y == 0,0], X[y==0,1], s=25, c='red', label='Cluster 1')
  plot.scatter(X[y == 1,0], X[y==1,1], s=25, c='blue', label='Cluster 2')
  plot.scatter(X[y == 2,0], X[y==2,1], s=25, c='magenta', label='Cluster 3')
  plot.scatter(X[y == 3,0], X[y==3,1], s=25, c='cyan', label='Cluster 4')
  
  plot.scatter(kmeans.cluster_centers_[:,0], kmeans.cluster_centers_[:,1], s=25, c='yellow', label='Centroid')
  plot.title('KMeans Clustering')
  plot.xlabel('Acousticness')
  plot.ylabel('Danceability')
  plot.legend()
  plot.show()
  </code></pre>
  
  <p>Here it's my code for clustering with 2 variables.</p>