【发布时间】:2018-05-10 08:56:10
【问题描述】:
我一直在尝试将 Python 中的前一个和下一个数字相乘,但我总是得到不同的错误。这就是我一直在做的:
u=[1, 41, 56, 80]
def Filter(vel):
global firstDerivative
firstDerivative = np.repeat(None, len(vel))
for index, obj in enumerate(vel):
if index !=0 & index !=len(vel-1):
firstDerivative = (vel[index-1]*vel[index+1])/2
Filter(u)
出现以下错误:
TypeError: unsupported operand type(s) for -: 'list' and 'int'
其实我也试过map,但是id不行。
【问题讨论】:
-
你的数据是什么?
-
给出你的输入数据!?你这里的“你”是什么?
-
除了
np.repeat的使用之外,numpy还有什么用? -
对不起,我编辑了它
-
错误在
len(vel-1)。vel是一个列表。没有为此定义减号。len(vel)-1怎么样?
标签: python python-3.x numpy indexing