我认识了
py_get_attr_impl(x,name,silent)中的错误:AttributeError:'DataFrame'对象没有属性'dtype'
在 R 中使用 reticulate 包在 R 中调用 python 代码。
python中的代码运行正常。我不确定这个错误来自哪里。我正在使用 pvlib python 库在构建数据库中调用一些。
我的代码是 R 是:
library('reticulate')
pd <- import('pandas')
pvlib <- import('pvlib')
np <- import('numpy')
sandia_modules = pvlib$pvsystem$retrieve_sam('SandiaMod')
cec_inverters = pvlib$pvsystem$retrieve_sam("CECInverter")
cec_inverters = pvlib$pvsystem$retrieve_sam("CECInverter")
当我在 python 中运行代码时遇到问题,但在 R 中运行相同的命令却给了我错误。我不确定问题是什么。请帮我解决这个问题。
python中类似的代码是:
import pandas as pd
import numpy as np
import pvlib
sandia_modules = pvlib.pvsystem.retrieve_sam('SandiaMod')
cec_inverters = pvlib.pvsystem.retrieve_sam('cecinverter')
我试图寻找解决方案,但到目前为止没有发现任何有用的东西。
这是回溯:
10: stop(list(message = "AttributeError: 'DataFrame' object has no attribute 'dtype'",
call = py_get_attr_impl(x, name, silent), cppstack = list(
file = "", line = -1L, stack = "C++ stack not available on this system")))
9: .Call(`_reticulate_py_get_attr_impl`, x, name, silent)
8: py_get_attr_impl(x, name, silent)
7: py_get_attr(x, name)
6: `$.python.builtin.object`(x[[column]], "dtype")
5: x[[column]]$dtype
4: py_to_r(x[[column]]$dtype$name)
3: py_to_r.pandas.core.frame.DataFrame(result)
2: py_to_r(result)
1: pvlib$pvsystem$retrieve_sam("CECInverter")