NumPy | Python Methods and Functions

With the ` `

method we can set ** Numpy matrix.itemset () ** ** elements ** in a given matrix, just ` `

index number and item. ** Numpy matrix .itemset () **

Syntax:`matrix.itemset (index, item)`

Return:Return new matrix having item

` ` ** Example # 1: **

In this example, we can see that we can set an element using the ` matrix.itemset () `

index number and element.

** **

` # import an important module into python `

` import `

` numpy as np `

` # make a matrix with NumPy `

` gfg `

` = `` np.matrix (`

` `[6, 1; 2, 3] ``

`) `

` ` ` `

` # applying the matrix.itemset () method `

` gfg.itemset ((`

` 1 `

`, `

` 0 `

`), `

` 5 `

`) `

` print `

` (gfg) `

** Exit:**

[[6 1] [5 3]]

** Example # 2: **

` # import an important module into python `

` import `

` numpy as np `

` # make a matrix with NumPy `

gfg ` = `

` np.matrix (`

` ` [1, 2, 3; 4, 5, 6; 7, 8, 9] ``

`) `

` `

` # applying the matrix.itemset () method `

` gfg.itemset ((`

` 2 `

`, `

` 0 `

`), `

` 10 `

`) `

` `

` print `

` (gfg) `

` `

** Exit:**

[[1 2 3] [4 5 6] [10 8 9]]

Vincent Bumgarner has been designing software for nearly 20 years, working in many languages on nearly as many platforms. He started using Splunk in 2007 and has enjoyed watching the product evolve ov...

10/07/2020

A Problem-Solver’s Guide to Building Real-World Intelligent Systems. Data is the new oil and Machine Learning is a powerful concept and framework for making the best out of it. In this age of aut...

23/09/2020

Computer Age Statistical Inference: Algorithms, Evidence, and Data Science (Institute of Mathematical Statistics Monographs, Series Number 6). The twenty-first century has seen a breathtaking expan...

28/08/2021

I remember one day, when I was about 15, my little cousin had come over. Being the good elder sister that I was, I spent time with her outside in the garden, while all the adults were inside having a ...

23/09/2020

X
# Submit new EBook