Skip to content Skip to sidebar Skip to footer

Countvectorizer On List Of Integers

I have list of integers as below: mylist = [111,113,114,115,112,115,234,643,565,.....] I have many lists like this with more than 500 integers on which I wanted to run CountVecto

Solution 1:

For your case, its redundant to use map with lambda, that might be the reason for the slow down, you could just use map without lambda like below

mylist = [111,113,114,115,112,115,234,643,565]
mylist_string = map(str, mylist) # use list(map(str, mylist)) for python 3
# ['111', '113', '114', '115', '112', '115', '234', '643', '565']

alternatively, you could try list comprehension

mylist = [111,113,114,115,112,115,234,643,565]
mylist_string = [str(x) for x in mylist]
# ['111', '113', '114', '115', '112', '115', '234', '643', '565']

Post a Comment for "Countvectorizer On List Of Integers"