[FIXED] convert an array to list in python

Issue

my code is : km = KMeans(n_clusters=2, init='k-means++', max_iter=100, n_init=1,verbose=0) predict=[]
predict.append(km.fit_predict(matrix))
the result is :[array([0,0,1,1,0])]

then I want to zip this result by list of string the result of zip is a list with one member because it assume*[array([0,0,1,1,0])]* as a list that has one member.

what should I do?


Solution

The function is returning a list with one array in it. So, you should be able to zip it with:

zip(list_of_strings, result[0])


Answered By - Eric Fredine
Answer Checked By - Timothy Miller (Python.Easybugfix Admin)

Related Posts

Post a Comment