title: Python kmeans value error
body: <p>I am trying to pass a pandas dataframe to the kmeans algorithm of the sklearn package. The dataframe has a date index with 52 dates (one per week) and the columns are different articles. The column values are the selling quantity of the corresponding week. For a better calculation I calculated the percentage change and that's how it looks like:</p>
  
  <pre><code>ARTICLE         47070868       489070875       29470899       99070943       \
  DATE                                                                     
  2017-01-02       0.000000       0.000000       0.000000       0.000000   
  2017-01-09      -0.015625      -0.074928      -0.083333       0.230769   
  2017-01-16       0.232804       0.007788       0.284091       0.062500   
  2017-01-23       0.051502       0.174652       0.011799       0.117647   
  2017-01-30       0.200000      -0.082895       0.008746       0.807018   
  2017-02-06       0.057823       0.040172      -0.020231      -0.411003   
  2017-02-13       0.000000      -0.037241      -0.014749      -0.087912   
  2017-02-20       0.125402       0.259312       0.218563       0.138554   
  2017-02-27      -0.265714      -0.271900      -0.233415      -0.343915   
  2017-03-06       0.470817       0.293750       0.448718       0.661290   
  2017-03-13       0.002646       0.013285      -0.057522      -0.048544 
  </code></pre>
  
  <p>The dataframe has 52 rows and 8753 columns. if i pass the dataframe to the kmeans algorithm I get the following error:</p>
  
  <blockquote>
    <p>ValueError: x and y must have same first dimension, but have shapes (52,) and (8753,)</p>
  </blockquote>
  
  <p>Here is the code: </p>
  
  <pre><code>kmeans = KMeans(n_clusters=3, random_state=0).fit(data_pct_change)
  print(kmeans.labels_)
  np.savetxt('log_sebastian2017.txt', kmeans.labels_, newline="\n")
  for i, cluster_center in enumerate(kmeans.cluster_centers_):
          plp.plot(data_pct_change.index, cluster_center, label='Center {0}'.format(i))
  plp.legend(loc='best')
  plp.show()
  </code></pre>
  
  <p>The error is thrown in the loop when trying to plot.<br>
  If I do this code:  </p>
  
  <pre><code>kmeans = KMeans(n_clusters=3, random_state=0).fit(data_pct_change)
  print(kmeans.labels_)
  np.savetxt('log_sebastian2017.txt', kmeans.labels_, newline="\n")
  for i, cluster_center in enumerate(kmeans.cluster_centers_):
          plp.plot(cluster_center, label='Center {0}'.format(i))
  plp.legend(loc='best')
  plp.show()
  </code></pre>
  
  <p>it works fine, but the scale of the x- and y axis is incorrect, it reaches on x from 0 to about 8700 (probably 8753, the number of columns) and on y from 0 to 10000 (which is also wrong, the maximum percentage change in the dataframe is 17,6).</p>
  
  <p>What am I doing wrong here? Also the amount of generated labels is wrong (in both cases the algorithm prints an array of length 52 for <code>kmean.labels_</code>, but should be 8573)</p>
  
  <p>Can someone help me to do this clustering correctly? Is my dataframe the wrong way round for the kmeans?</p>