Reputation: 1115
I think I understand the error, that you cannot change a certain index of certain types of data, however, I don't understand where in the process this is happening at.
I'm trying to take a string (tweet), split it into words, run the words through the w2v dictionary (if they exist in the vocab), and then sum the values. I don't understand why and where I'm assigning an WordToVector item (w2v) and receiving this error.
n['new'] = n['tweet'].apply(lambda x: np.sum([x for w2v[i] in x.split() if i in w2v.vocab]))
'Word2VecKeyedVectors' object does not support item assignment
Upvotes: 1
Views: 697
Reputation: 407
I can't see the rest of your code, but just looking at this part, the error seems to come from the inner for loop:
[x for w2v[i] in x.split() if i in w2v.vocab]
It appears that the w2v object is of type 'Word2VecKeyedVectors'. So you're trying to assign to w2v[i] each word you find on your x.split(). And this gives the error
'Word2VecKeyedVectors' object does not support item assignment
Upvotes: 1