mei825423531 发表于 2022-7-3 01:00:07

numba 加速 Python for循环

用numba来加速Python 循环执行不下去{:5_107:} ,求大神指点一二~

#代码
@nb.jit()
def nb1():
    for i in range(len(df1)):
      if df1.iloc['首3邮编'] < '350':
            df1['落地点'].at = 'JFK'
      elif df1.iloc['首3邮编'] >= '790':
            df1['落地点'].at = 'LAX'
      else:
            df1['落地点'].at = 'ORD'


nb1()

# error
Compilation is falling back to object mode WITHOUT looplifting enabled because Function "nb1" failed type inference due to: Cannot determine Numba type of <class 'numba.core.dispatcher.LiftedLoop'>

File "面料克重2.py", line 67:
def nb1():
    for i in range(len(df1)):
    ^

@nb.jit()


File "面料克重2.py", line 67:
def nb1():
    for i in range(len(df1)):
    ^

warnings.warn(errors.NumbaDeprecationWarning(msg,

傻眼貓咪 发表于 2022-7-3 13:08:53

本帖最后由 傻眼貓咪 于 2022-7-3 13:25 编辑

@nb.jit?

z5560636 发表于 2022-7-6 09:59:57

@nb.jit()

你这个是啥? 装饰器的话,也没看到你引入包啊? 是你自己在逗自己玩,还是别人在逗你玩?
页: [1]
查看完整版本: numba 加速 Python for循环