如何将数据与 CountVectorizer 功能合并
How do I merge data with CountVectorizer features
这是我的数据集
body customer_id name
14828 Thank you to apply to us. 5458 Sender A
23117 Congratulation your application is accepted. 5136 Sender B
23125 Your OTP will expire in 10 minutes. 5136 Sender A
这是我的代码
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
b = a['body']
vect = CountVectorizer()
vect.fit(b)
X_vect=vect.transform(b)
pd.DataFrame(X_vect.toarray(), columns=vect.get_feature_names())
输出为
10 application apply ... your
0 0 0 1 0
1 0 1 0 1
2 1 0 0 1
我需要的是
body customer_id name 10 application apply ... your
14828 Thank you to apply to us. 5458 Sender A 0 0 1 0
23117 Congratulation your application is accepted. 5136 Sender B 0 1 0 1
23125 Your OTP will expire in 10 minutes. 5136 Sender A 1 0 0 1
我该怎么做?我还是希望能用CountVectorizer
以后可以修改功能
这是我的数据集
body customer_id name
14828 Thank you to apply to us. 5458 Sender A
23117 Congratulation your application is accepted. 5136 Sender B
23125 Your OTP will expire in 10 minutes. 5136 Sender A
这是我的代码
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
b = a['body']
vect = CountVectorizer()
vect.fit(b)
X_vect=vect.transform(b)
pd.DataFrame(X_vect.toarray(), columns=vect.get_feature_names())
输出为
10 application apply ... your
0 0 0 1 0
1 0 1 0 1
2 1 0 0 1
我需要的是
body customer_id name 10 application apply ... your
14828 Thank you to apply to us. 5458 Sender A 0 0 1 0
23117 Congratulation your application is accepted. 5136 Sender B 0 1 0 1
23125 Your OTP will expire in 10 minutes. 5136 Sender A 1 0 0 1
我该怎么做?我还是希望能用CountVectorizer
以后可以修改功能