Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy apply function to array

import numpy as np

arr = np.array([1,2,3,4])
print(np.apply_along_axis(lambda x : x ** 2, 0, arr))

#Output: array([ 1,  4,  9, 16])
Comment

PREVIOUS NEXT
Code Example
Python :: find the area of a circle in python 
Python :: set cookie in python requests 
Python :: read excel file spyder 
Python :: print a text in python 
Python :: how to count range in django template 
Python :: sort list in python by substring 
Python :: slack send message python 
Python :: how to iterate pyspark dataframe 
Python :: python get current month 
Python :: check if is the last element in list python 
Python :: convert from 12 hrs to 24 python 
Python :: dropping nan in pandas dataframe 
Python :: primary key django model 
Python :: if django 
Python :: convert keys to values in python 
Python :: merge dataframe 
Python :: python print in one line 
Python :: python make a new window 
Python :: how to take unknown number of inputs in python 
Python :: remove empty lines from file python 
Python :: python turn true or false into 0 or 1 
Python :: python check if array is sorted 
Python :: aiohttp get 
Python :: how to check nth prime in python 
Python :: python read from stdin 
Python :: np.rand.randint 
Python :: python import worldcloud 
Python :: how to underline text in tkinter 
Python :: free python script hosting 
Python :: python [remote rejected] master - master (pre-receive hook declined) 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =