'It is possible to do CountVectorizer matrix with more than one parameters?
I am trying to count how many times a word in sentences is used by a particular users and role. This code is work as expected, but I dont have any idea what if I want to add one more criteria in my matrix.
My dataframe is:
Sentence_list=[['A', 'B','text1'],['C','D', 'text2'],['E','F', 'text3']]
Header names are:
col 0: index_name
col 1: role
col 2: text
And this is what I do with my code (that is work as expected):
matrix_means=vectorizer.fit_transform(df_train['text'])
count_array_means=matrix_means.toarray()
counts_means=pd.DataFrame(data=count_array_means, index=df_train.index_name, columns=vectorizer.get_feature_names())
print(counts_means)
The expected output should be like this:
index_name role token1 token2 token3
0 A B 2 0 1
1 C D 0 1 1
2 E F 1 0 0
Is it possible to do something like that using CountVectorizer? I really appreciate for your help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
