title: How to apply k-means clustering to dataframe with mixed data?
body: <p>i have a dataframe with mixed data. The data includes different categories, like location, employee ID, job code, and some other values. I converted to indicator variables:</p>
  <p><code>data_norm = pd.get_dummies(data)</code>
  then, my dataset looks like 4414 rows × 12995 columns
  then tried using a basic implementation of k-means:</p>
  <pre><code>kmeans = KMeans(6)
  clusters = kmeans.fit_predict(data_norm_df)
  labels = pd.DataFrame(clusters)
  labeleddata = pd.concat((data,labels),axis=1)
  labeleddata = labeleddata.rename({0:'labels'},axis=1)
  </code></pre>
  <p>but get this error: <code>ValueError: n_samples=1 should be &gt;= n_clusters=6.</code></p>
  <p>i also tried this:</p>
  <pre><code>k_means = KMeans(n_clusters=3, random_state=0)
  k_means.fit(data_norm_df)
  clusters = k_means.fit_predict(data_norm_df)
  labels = pd.DataFrame(clusters)
  labeleddata = pd.concat((data,labels),axis=1)
  labeleddata = labeleddata.rename({0:'labels'},axis=1)
  </code></pre>
  <p>I am not sure why it assumes there is only one sample as my dataset has 4414 rows. Please help!</p>