Home > Software design >  filling zeros in the range of rows
filling zeros in the range of rows

Time:01-20

I have a matrix file that contain 512 rows and 10 columns, I want to fill zeros from rows number 256 to 512 in every columns,Can anybody suggest a smart solution for it.

my script:

import numpy as np
data=np.loadtxt('input_data')  #512x10
data=np.zeros(data,256:512)

However, it doesn't fill the zeros in the expected range of rows.

CodePudding user response:

Like this:

import numpy as np
data=np.loadtxt('input_data')  #512x10  
data[256:513, :] = 0
  •  Tags:  
  • Related