Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

map to numpy array

>>> import numpy as np    
>>> f = lambda x: x**2
>>> seq = map(f, range(5))
>>> np.fromiter(seq, dtype=np.int)
array([ 0,  1,  4,  9, 16])
Comment

map numpy array

import numpy as np 
x = np.array([1, 2, 3, 4, 5])
# Obtain array of square of each element in x
squarer = lambda t: t ** 2
squares = np.array([squarer(xi) for xi in x])
Comment

PREVIOUS NEXT
Code Example
Python :: flow of control in python 
Python :: run ansible playbook python 
Python :: else if 
Python :: set intersection 
Python :: tf dataset 
Python :: how to find the last element of list in python 
Python :: convert mixed number string to float 
Python :: python environment variable 
Python :: can we use else without if in python 
Python :: js choice function 
Python :: or operator in python 
Python :: string comparison in python 
Python :: sorted lambda 
Python :: Remove an element from a Python list Using pop() method 
Python :: repeat string python 
Python :: how to run other python files in python 
Python :: check permissions django template 
Python :: generator expression 
Python :: import a module in python 
Python :: custom permission class django rest framework 
Python :: oops python self and making an object of a class and calling function 
Python :: problem solving with python 
Python :: how to import packages in python 
Python :: python dict 
Python :: django select_related and prefetch_related 
Python :: django serializer method field read write 
Python :: python list of deeper paths 
Python :: python Entry default text 
Python :: how to join two string series python 
Python :: python zeromq timeout 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =