>>> import numpy as np
>>> a = np.array([1,2,3,4,5,6])
>>> a = abs(a - 125) # could use np.abs. It does the same thing, but might be more clear that you expect to get an ndarray instance as a result.
>>> a
array([124, 123, 122, 121, 120, 119])
>>> np.arctan(a)
array([ 1.56273199, 1.56266642, 1.56259979, 1.56253205, 1.56246319,
1.56239316])
只需使用^{} :
您可以使用列表理解:
可以使用列表理解将
atan
函数应用于数组的每个元素:相关问题 更多 >
编程相关推荐