[英]How to solve type object 'Series' has no attribute '_get_dtypes' error using modin.pandas?
[英]Faster pandas apply using modin.pandas
尝试使用 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)
它适用于默认的熊猫,但使用 modin 会引发此错误:
ValueError: can not merge DataFrame with instance of type <class 'modin.pandas.series.Series'>
Essay 是 DataFrame 中名为“data”的文本列
正如这个问题的答案所暗示的那样,您可能会收到此错误,因为您正在将pandas.Dataframe
与modin.Series
合并。 对于您的示例,尝试使用modin.pandas.DataFrame(data)
将data
转换为modin.pandas.DataFrame(data)
帧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.