Home > Enterprise >  Increase NumPy array items by 1 in Python
Increase NumPy array items by 1 in Python

Time:07-13

I want to increase all the array items by 1 i.e from [i,j] to [i 1,j 1]. I have shared the expected output.

import numpy as np
I=np.array([[ 0,  2],
       [ 0,  3],
       [ 0,  5],
       [ 1,  6]])

The expected output is

array([[ 1,  3],
       [ 1,  4],
       [ 1,  6],
       [ 2,  7]])

CodePudding user response:

Try: I = I 1 That operation will increment each element

  • Related