我有一个按列引用的numpy数组,例如df['x']
,df['y']
。
将其提供给Numba的最佳方法是什么,以便我可以在nopython
模式下运行该功能?
或者在Numba中处理数据帧的最佳方法是什么,以便我可以按名称访问列?
答案 0 :(得分:3)
06-Nov-2018 17:19:24.353 WARNING [Handling GET /jenkins/job/testing-jacoco-code-coverage-reports/configure from 0:0:0:0:0:0:0:1 : http-nio-8080-exec-3 Job/configure.jelly Project/configure-entries.jelly] hudson.ExpressionFactory2$JexlExpression.evaluate Caught exception evaluating: i.descriptor in /jenkins/job/testing-jacoco-code-coverage-reports/configure. Reason: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
Caused by: java.lang.AssertionError: class hudson.plugins.jacoco.JacocoPublisher is missing its descriptor
at jenkins.model.Jenkins.getDescriptorOrDie(Jenkins.java:1517)
at hudson.tasks.Publisher.getDescriptor(Publisher.java:122)
at hudson.tasks.Recorder.getDescriptor(Recorder.java:51)
at hudson.plugins.jacoco.JacocoPublisher.getDescriptor(JacocoPublisher.java:775)
... 168 more
旨在直接与NumPy数组一起使用。因此,您不应该希望将数据帧或结构化数组提供给numba
函数。您可以将数组作为单独的参数输入。例如:
numba
from numba import njit
@njit
def func(A, B):
# some logic
arr = A + B
return arr
df['z'] = func(df['x'].values, df['y'].values)
函数中解压缩二维数组这是特例,您的数据框系列都具有相同的类型。如果不确定系列类型,请检查numba
。您可以输入一个数组并在df.dtypes
内执行解压缩:
numba