numpy.place(array, mask, vals) : make changes in the array according the parameters – conditions and value(uses first N-values to put into array as per the mask being set by the user). It works opposite to numpy.extract().
array : [ndarray] Input array, we need to make changes into mask : [array_like]Boolean that must have same size as that of the input array value : Values to put into the array. Based on the mask condition it adds only N-elements to the array. If in case values in val are smaller than the mask, same values get repeated.
Array with change elements i.e. new elements being put
Original array : [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] Putting up elements to array: [[ 0 1 2 3] [ 4 5 15 25] [35 15 25 35]] Original array1 : [[ 0 1 2 3] [ 4 5 15 25] [35 15 25 35]] Putting new elements to array1 : [[ 0 1 2] [44 55 44]]
These codes won’t run on online-ID. Please run them on your systems to explore the working.
This article is contributed by Mohit Gupta_OMG 😀. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Python - Read blob object in python using wand library
- Python | Convert list to Python array
- MySQL-Connector-Python module in Python
- Important differences between Python 2.x and Python 3.x with examples
- Python | Index of Non-Zero elements in Python list
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- twitter-text-python (ttp) module - Python
- Python | PRAW - Python Reddit API Wrapper
- Python | Sort Python Dictionaries by Key or Value
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Visualizing O(n) using Python
- try-except vs If in Python
- C Vs Python
- Python Set | pop()
- gcd() in Python
- bin() in Python