从R中获取Python函数而不导入模块

2024-05-28 18:24:50 发布

您现在位置:Python中文网/ 问答频道 /正文

网状文档说,我可以像使用source_Python()函数来源代码R脚本一样来源代码任何Python脚本。我试过他们提供的例子,但对我来说不管用。我收到“没有名为熊猫的模块”错误。在

首先,我指定python的路径

library(reticulate)
use_python("/Users/fberhane/anaconda3/bin/python", required=TRUE)

然后将下面的python代码另存为航班.py在

^{pr2}$

然后,在将上面的python代码保存为航班.py在

source_python("flights.py")
flights <- read_flights("flights.csv")

library(ggplot2)
 ggplot(flights, aes(carrier, arr_delay)) + geom_point() + geom_jitter()

但是我得到的错误信息是没有叫做pandas的模块。在


Tags: 模块函数代码文档py脚本source源代码

热门问题