TRIGGERBLOCK
Thursday, May 23, 2019
Numpy : Lambda / map / vectorize
Numpy : Lambda / map / vectorize
import numpy as np
def myfunc(a, b):
if a > b:
return a - b
else:
return a + b
n1=np.array([1,2,3])
n2=np.array([5,4,3])
vfunc = np.vectorize(myfunc)
print(vfunc(n1,n2))
Output :
[6 6 6]
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment