How do I modify particular a row or column of a NumPy array?
For example I have a NumPy array as follows:
P = array([[1, 2, 3],
[4, 5, 6]])
How do I change the elements of first row, [1, 2, 3]
, to [7, 8, 9]
so that the P
will become:
P = array([[7, 8, 9],
[4, 5, 6]])
Similarly, how do I change second column values, [2, 5]
, to [7, 8]
?
P = array([[1, 7, 3],
[4, 8, 6]])