import numpy as np
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
a = np.diff(list1)
b = np.sign(list1)
list2 = np.array([70, 80, 90, 60, 50, 80, 40, 70])
c = np.piecewise(list2, [list2 < 60, list2 == 60, list2 > 60], [-1, 0, 1]) #源数组, 条件序列,取值序列
print(a)
print(b)
print(c)
numpy 符号数组
最新推荐文章于 2023-03-27 16:52:55 发布