I've got a list of words, about 273000 of them in the list Word_array
There are about 17000 unique words, and they're stored in Word_arrayU
I want a count for each one
#make bag of worsds
Word_arrayU = np.unique(Word_array)
wordBag = [['0','0'] for _ in range(len(Word_array))] #prealocate necessary space
i=0
while i< len(Word_arrayU): #for each unique word
wordBag[i][0] = Word_arrayU[i]
#I think this is the part that takes a long time. summing up a list comprehension with a conditional. Just seems sloppy
wordBag[i][1]=sum([1 if x == Word_arrayU[i] else 0 for x in Word_array])
i=i+1
summing up a list comprehension with a conditional. Just seems sloppy; is there a better way to do it?