'How to include string data into my k-means?

I'm trying to do k-means with datas that mostly are numbers like: money in the count, months inactive, customer age, etc... but also i have data that are strings like gender, marital status or education level.

When i try to run that code:

    kmeans = KMeans(n_clusters=22)
    kmeans.fit(x)
    identified_clusters = kmeans.fit_predict(x)
    identified_clusters

Shows an error that says: could not convert string to float: 'Existing Customer'

There is an example of the table data that i have to convert:

enter image description here

Note: click the image to see closely

Is there a way to include the stings data to the k-means?



Sources

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

Source: Stack Overflow

Solution Source