title: K-means, knee locator, not quite correct
body: <p>Using some codes I found here and in google, I have made a kmeans clustering algorithem based on Knee. locator:</p>
  <pre><code>def kmeans_clustering(data_set: pd.DataFrame, column: str, clusters_count: int):
      '''K means clustering on dataframe, choosing specific columns and cluster count'''
      data_set = data_set[column].to_numpy()
      data_values = data_set.reshape(-1, 1)
      kmeans = KMeans(n_clusters=clusters_count).fit(data_values)
      y = kmeans.fit_predict(data_values)  # prediction of k
      frame = pd.DataFrame(y, index=data_set.index)
      frame.index = frame.index[frame.index.isin(data_set.index)]
      return frame.join(data_set)
  
  wcss =[]
      for i in range(1, 11):
          kmeans = KMeans(n_clusters=i, init='k-means++', max_iter=300, n_init=10, random_state=0)
          kmeans.fit(RTN)
          wcss.append(kmeans.inertia_)
      kn = KneeLocator(
                          range(1, 11), wcss,  # put range in variable
                          curve='convex',
                          direction='decreasing', interp_method='interp1d')
  </code></pre>
  <p>............</p>
  <pre><code>for i in RTN:
      frame = kmeans_clustering(data_set=RTN, column= val, clusters_count= kn.knee)
  </code></pre>
  <p>............</p>
  <p>My dataframe is &quot;RTN&quot;. Columns represnted by &quot;val&quot; (has around thousand). After running the code I get the following warning:</p>
  <pre><code>ConvergenceWarning: Number of distinct clusters (3) found smaller than n_clusters (4). Possibly due to duplicate points in X.
    kmeans = KMeans(n_clusters=clusters_count).fit(data_values)
  C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sklearn\cluster\_kmeans.py:1122: ConvergenceWarning: Number of distinct clusters (3) found smaller than n_clusters (4). Possibly due to duplicate points in X.
    return self.fit(X, sample_weight=sample_weight).labels_
  </code></pre>
  <p>I understand that I possibly have done a &quot;double operation&quot;, but where did it go wrong?</p>