尝试使用 modin.pandas 将所有内核用于此应用功能
from nltk.sentiment.vader import SentimentIntensityAnalyzer
sid = SentimentIntensityAnalyzer()
# sentiment Score of essay
data = data.merge(data.essay.apply(lambda s: pd.Series({'neg':sid.polarity_scores(s)['neg'],
'neu':sid.polarity_scores(s)['neu'],
'pos':sid.polarity_scores(s)['pos'],
'compound':sid.polarity_scores(s)['compound']})),
left_index=True, right_index=True)
它适用于默认的 pandas,但使用 modin 会引发此错误:
ValueError: can not merge DataFrame with instance of type <class 'modin.pandas.series.Series'>
文章是 DataFrame 中名为“data”的文本列