I have an numpy array which I have initialized and looks like this:
pulse = np.ndarray(shape = (300, 10001, 3), dtype = float)
I want to fill this array with some data I am reading from a file. An example of the way I want to fill it looks like this:
pulse[0][0][0] = 1
pulse[0][1:10001][0] = data
where data is an array of 10000 elements.
Could this be done using append or another function of numpy?
The problem with you're current approach is that you're assigning to a copy of the data, and hence the original array remains unchanged. Instead assign to a view of the array (which is known as slice assignment), this way you'll be modifying in-place:
pulse[0, 1:10001, 0] = data
This should work :
pulse[0,0,0]= 1
pulse[0,1:1001,0]= data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With