I want to write a function where if an array is equal to or less than 0 it will replace the values after (and including) that index with 0. The Numbers have the 7th element less than 0 being -1, thus elements including the 7th element to 10th element values will be replaced by 0. How could I configure the the np.where function so it gives the expected result values.
Code:
Numbers = np.array([87. ,4., 4.1, 8.5, 10 , 20, 22.3, -1, 1, 60, -4]) Expected Output:
[87. ,4., 4.1, 8.5, 10 , 20, 22.3, 0, 0, 0, 0] https://stackoverflow.com/questions/66095008/modifying-a-chunk-of-arrays-in-numpy-python February 08, 2021 at 09:54AM
没有评论:
发表评论