from sklearn.feature_extraction.text import TfidfVectorizer
import pandas as pd
df = pd.read_excel('./TfidfVectorizer_sklearn.xlsx')
for i in df.columns: # loop through every column
tfidf_vectorizer = TfidfVectorizer()
print(df.loc[:, i].values)
X = tfidf_vectorizer.fit_transform(df.loc[:, i].values) # select column all values
print(tfidf_vectorizer.get_feature_names_out())
print(X.shape)
1条答案
按热度按时间j8ag8udp1#
我希望这对您的解决方案有效,使用 Dataframe 的.values属性