Home > Back-end >  Using Numpy to update one column by the square root of those column values
Using Numpy to update one column by the square root of those column values

Time:06-16

Given an array update the second column by the square root of those values.

CodePudding user response:

As rafaelc suggested, you can use np.sqrt on a specific column.

a = np.array([[1.,2.,3.],[1.,2.,3.]])
a[:,1] = np.sqrt(a[:,1])

a has two rows and three columns. a[:,1] is the second column.

  • Related