Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

vectorize function python numpy

>>> vfunc = np.vectorize(myfunc)
>>> vfunc([1, 2, 3, 4], 2)
array([3, 4, 1, 2])
Comment

np.vectorize

import numpy as np

def myfunc(a):
    # Return True if a>b, otherwise False"
    if a > 2:
        return bool(True)
    else: return bool(False)

vfunc = np.vectorize(myfunc) # vectorize iterates function.
vfunc([1, 2, 3, 4])
# array([False, False,  True,  True])
Comment

PREVIOUS NEXT
Code Example
Python :: numpy round to nearest 5 
Python :: download youtube video 
Python :: concatenating strings in python 
Python :: walrus operator python 3.8 
Python :: dictionary append value python 
Python :: can a function output be save as a variable python 
Python :: instance method in python 
Python :: import library to stop warnings in jupyter 
Python :: iterating over tuples in python 
Python :: Insert list element at specific index 
Python :: create exact window size tkinter 
Python :: to divide or not to divide codechef 
Python :: knuth morris pratt algorithm 
Python :: how to drop columns from pandas dataframe 
Python :: onedrive python upload 
Python :: pytest debug test 
Python :: python while loop guessing game 
Python :: how to get a row of a dataframe with subset columns in python 
Python :: curl to python 
Python :: black python 
Python :: how to run python in atom 
Python :: how to join basename and directory in python os 
Python :: read data from gooogle cloud storage 
Python :: python flask rest api 
Python :: python select file in folder given extension 
Python :: Changing the data type to category 
Python :: How to Loop Through Sets in python 
Python :: pytorch inverse 
Python :: python list sort key lambda on equal other function 
Python :: datetime to epoch 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =