Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

power of array

>> import numpy as np 

>> x1 = np.arange(6)

>> x1
[0, 1, 2, 3, 4, 5]

>> np.power(x1, 3)
array([  0,   1,   8,  27,  64, 125])

# allso works with raising one array to the power of another 
>> x2 = np.array([[1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1]])

>> x2
array([[1, 2, 3, 3, 2, 1],
       [1, 2, 3, 3, 2, 1]])

>> np.power(x1, x2)
array([[ 0,  1,  8, 27, 16,  5],
       [ 0,  1,  8, 27, 16,  5]])
Comment

PREVIOUS NEXT
Code Example
Python :: count no of nan in a 2d array python 
Python :: django trim string whitespace 
Python :: python tkinter ttk 
Python :: np matrix drop zero column 
Python :: python turtle delay 
Python :: pandas df describe() 
Python :: python undefined 
Python :: python string generator 
Python :: axios django csrf 
Python :: print example in python 
Python :: how to automatically install python packages 
Python :: raw input python 
Python :: django charfield force lowercase 
Python :: python multiply 2 variables 
Python :: notebook cell print output to file 
Python :: add 1 to all columns in numpy array 
Python :: python threading return value 
Python :: iterate over a set python 
Python :: pandas read csv dtype list 
Python :: piecewise linear regression python 
Python :: re.match python 
Python :: datetime columns only extract date pandas 
Python :: numpy concatenation array 
Python :: plotly coordinates mapping 
Python :: python convert ascii to char 
Python :: .lift tkinter 
Python :: flask form 
Python :: adfuller test in python 
Python :: python parse int as string 
Python :: python beautifulsoup get option tag value 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =