'ValueError: could not convert string to float: 'What is clustering?'

For context, am trying to apply k-means clustering on a dataset and the code seems to be stuck here with the same error. No matter how I change the dataset it picks up the value error on the last line of the dataset. Here's the code am using

# importing libraries    
import numpy as nm    
import matplotlib.pyplot as mtp    
import pandas as pd
#finding optimal number of clusters using the elbow method  
from sklearn.cluster import KMeans

# Importing the dataset  
dataset = pd.read_csv('damn_boi.csv')

x = dataset.iloc[:, [1, 2]].values

#training the K-means model on a dataset  
kmeans = KMeans(n_clusters=3, init='k-means++', random_state= 42)  
y_predict= kmeans.fit_predict(x)

Edit: Error trace add

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-14-c7e89c41fbbb> in <module>
     13 #training the K-means model on a dataset
     14 kmeans = KMeans(n_clusters=3, init='k-means++', random_state= 42)
---> 15 y_predict= kmeans.fit_predict(x)

~\lib\site-packages\sklearn\cluster\_kmeans.py in fit_predict(self, X, y, sample_weight)
   1253             Index of the cluster each sample belongs to.
   1254         """
-> 1255         return self.fit(X, sample_weight=sample_weight).labels_
   1256 
   1257     def fit_transform(self, X, y=None, sample_weight=None):

~\lib\site-packages\sklearn\cluster\_kmeans.py in fit(self, X, y, sample_weight)
   1141             order="C",
   1142             copy=self.copy_x,
-> 1143             accept_large_sparse=False,
   1144         )
   1145 

~\lib\site-packages\sklearn\base.py in _validate_data(self, X, y, reset, validate_separately, **check_params)
    564             raise ValueError("Validation should be done on X, y or both.")
    565         elif not no_val_X and no_val_y:
--> 566             X = check_array(X, **check_params)
    567             out = X
    568         elif no_val_X and not no_val_y:

~\lib\site-packages\sklearn\utils\validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator)
    744                     array = array.astype(dtype, casting="unsafe", copy=False)
    745                 else:
--> 746                     array = np.asarray(array, order=order, dtype=dtype)
    747             except ComplexWarning as complex_warning:
    748                 raise ValueError(

~\AppData\Roaming\Python\Python37\site-packages\numpy\core\_asarray.py in asarray(a, dtype, order)
     83 
     84     """
---> 85     return array(a, dtype, copy=False, order=order)
     86 
     87 

ValueError: could not convert string to float: 'What is clustering?'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source