python - 使用 modin.pandas 应用更快的 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)
它适用于默认的 pandas,但使用 modin 会引发此错误:
ValueError: can not merge DataFrame with instance of type <class 'modin.pandas.series.Series'>
文章是 DataFrame 中名为“data”的文本列
解决方案
正如这个问题的答案所暗示的那样,您可能会收到此错误,因为您正在将 apandas.Dataframe
与 a合并modin.Series
。对于您的示例,请尝试data
使用modin.pandas.DataFrame(data)
.
推荐阅读
- hadoop - 带有 Hadoop HDFS 的 Apache Flink:错误的 FS 预期文件:///
- mysql - Sequelize 和 MySQL 关联
- vue.js - Vue / Vuex:计算内部的mapState未更新
- sql - 我无法从自定义架构中的函数撤消执行
- webpack - Webpack 将较少的字段转换为 css
- css - 在 Salesforce Commerce Cloud 中更改移动菜单的断点
- python - 如何在 Django 中创建用户时将电子邮件和名称字段添加到 SendMail 中
- python - 使用 Python 在目录中查找与模式匹配的文件,如果未找到则发送电子邮件
- c++ - free:删除动态创建的数组时指针无效
- python - html模板中的for循环并将值保存在变量中