📜  todense() - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:45.206000             🧑  作者: Mango

代码示例1
from sklearn.feature_extraction.text import TfidfVectorizer

tfidf = TfidfVectorizer(stop_words='english')

description = df['tokens'].astype(str)

dtm  = tfidf.fit_transform(description) 

dtm = pd.DataFrame(dtm.todense(), columns = tfidf.get_feature_names())

dtm.head()