How to add specific value to all numpy matrix (array 2D) elements in Python

1 Answer

0 votes
import numpy as np 
      
arr = np.array([[1, 2, 3, 4], 
                [5, 6, 7, 8]]) 
   
arr = arr.__add__(3) 

print(arr)
  
     
    
'''
run:
  
[[ 4  5  6  7]
 [ 8  9 10 11]]
    
'''

 



answered Feb 25, 2020 by avibootz
...