I have a numpy 2D array with a range of 800. Now I only want to use the elements from index range 600 to 700 and set all other values to np.nan. The Index of the lasting elements should be the same as before. The length of the array should be the same too. Thanks!
CodePudding user response:
import numpy as np
a = np.random.random ([800,4])
a[:600, :], a[700:, :] = np.nan, np.nan