![](/img/trans.png)
[英]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.