I have an array (100,72) and I need to clip only the values of some columns. For example, I want that only the negative values in the column from 15 to column 72 are set to 0
I have seen that using the np.clip() function it is not possible to do this.
Is there a quick way or do I have to decompose and reassemble the array?
Add a comment
|
1 Answer
Do this:
arr[:, 15:73] = np.clip(arr[:, 15:73], a_min = 0)
In general, if cols is the list of column indices, you can use arr[:, cols] to perform the operation selectively on the specified columns. Reference: numpy indexing.
1 Comment
Eric Hansen
This raises an error because the argument a_max was excluded.