我正在尝试将数据框列从 Python 传递到 Cython:
Python代码
evaluate_c(
AnimalLogicPy(data[COL_ANIMAL_ID].values,
data[COL_ANIMAL_POWER].values,
)
赛通代码
cpdef void evaluate_c(
int[:] animal_ids,
int[:] animal_power,
):
在 Python 端data[COL_ANIMAL_ID],data[COL_ANIMAL_POWER]类型为:int64
但是我收到以下错误:
ValueError: Buffer dtype mismatch, expected 'int' but got 'long'
我想int在 Cython 中使用值。我已经阅读了一些内容,我认为这是因为所讨论的数据框列属于int64我认为正在变得很长并且应该是int32.
我尝试在 Python 端使用以下方法更改类型:
data.astype({COL_ANIMAL_ID: 'int32'}).dtypes
data.astype({COL_ANIMAL_POWER: 'int32'}).dtypes
但我仍然得到 ValueError。
如何将 Python 端的列类型从 int64 更改为 int32?
繁花如伊
交互式爱情
随时随地看视频慕课网APP
相关分类