ModuleNotFoundError: 没有名为“pandas.rpy”的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45221609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ModuleNotFoundError: No module named 'pandas.rpy'
提问by Franck Dernoncourt
I'm trying to import pandas as pd
. I get ModuleNotFoundError: No module named 'pandas.rpy'
. Why? I use pandas 0.20.1 + python 3.6 x64 + Windows 7 .
我正在努力import pandas as pd
。我明白了ModuleNotFoundError: No module named 'pandas.rpy'
。为什么?我使用Pandas 0.20.1 + python 3.6 x64 + Windows 7。
Example:
例子:
import os
os.environ['R_HOME'] = 'C:\Program Files\R\R-3.4.0'
os.environ['R_USER'] = 'bob'
import rpy2.robjects as robjects
import pandas.rpy.common as com
import pandas as pd
Returns:
返回:
Traceback (most recent call last):
File "C:\doc\GitHub\proj\src\open_rdata.py", line 19, in <module>
import pandas.rpy.common as com
ModuleNotFoundError: No module named 'pandas.rpy'
回答by Ori
pandas.rpy
module was deprecated and later removed. It does not exist in the version you are currently using.
pandas.rpy
模块被弃用,后来被删除。它在您当前使用的版本中不存在。
You can either downgrade your pandas version, or better yet, have a look at the new rpy2
project.
您可以降级您的 Pandas 版本,或者更好的是,查看新rpy2
项目。
From pandas documentation:
来自Pandas文档:
Up to pandas 0.19, a pandas.rpy module existed with functionality to convert between pandas and rpy2 objects. This functionality now lives in the rpy2 project itself. See the updating section of the previous documentation for a guide to port your code from the removed pandas.rpy to rpy2 functions.
在 pandas 0.19 之前,存在一个 pandas.rpy 模块,具有在 pandas 和 rpy2 对象之间转换的功能。此功能现在存在于 rpy2 项目本身中。有关将代码从已删除的 pandas.rpy 移植到 rpy2 函数的指南,请参阅上一文档的更新部分。
You can see the rpy2 documentation here, and panda's reference for it here.
edit: per Analytical Monk's comment, corrected the phrasing to refer rpy2
as a different library, and not a part of pandas
编辑:根据分析僧侣的评论,更正了措辞以引用rpy2
不同的图书馆,而不是Pandas的一部分