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 :: dataframe to csv 
Python :: python vs java 
Python :: automatic regex generator python 
Python :: mnist 
Python :: jupyterthemes jplot 
Python :: python data insert 
Python :: Change Separator Value When Printing 
Python :: Chef in his Office codechef solution 
Python :: pandas group by decending 
Python :: An example of how to associate a color to each bar and plot a color bar 
Python :: quote_from_bytes() expected bytes 
Python :: python change version 
Python :: Import "sendgrid" could not be resolved django 
Python :: where is a package stored python 
Python :: select inverse with conditions pandas 
Python :: scikit learn decision tree 
Python :: python get colorscale 
Python :: check for changed model fields in djnago signal 
Python :: Python how to use __floordiv__ 
Python :: python string lower method 
Python :: NumPy fliplr Syntax 
Python :: how to pick the latest data entered django 
Python :: how to split a dataframe into train and test 
Python :: Converting a HDFDataset to numpy array 
Python :: Flatten List in Python With Itertools 
Python :: calculate the R^2 for X and Y python 
Python :: python send image client 
Python :: Object of type datetime is not JSON serializable 
Python :: how do i get auth user model dynamically in django? 
Python :: from future import division 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =