VOOZH about

URL: https://www.geeksforgeeks.org/python/numpy-put-python/

⇱ numpy.put() in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

numpy.put() in Python

Last Updated : 8 Mar, 2024

The numpy.put() function replaces specific elements of an array with given values of p_array. Array indexed works on flattened array. 
 

Syntax: numpy.put(array, indices, p_array, mode = 'raise')


Parameters : 

array : array_like, target array
indices : index of the values to be fetched
p_array : array_like, values to be placed in target array
mode : [{‘raise’, ‘wrap’, ‘clip’}, optional] mentions how out-of-bound indices will behave
 raise : [default]raise an error 
 wrap : wrap around
 clip : clip to the range


 

Output : 

After put : 
[-44, 1, -55, 3, 4]


 

Output : 

array([ 0, 1, 2, 3, -5])


Note : 
These codes won't run on online IDE's. So please, run them on your systems to explore the working.
 

Comment
Article Tags: