Hi all
I have a relatively simple problem concerning arrays but I have read through several python training packages looking for an appropriate function without success
Here is my problem. I have an array with various values in the array. let's say
a = [[1,2,3],[4,5,6],[7,8,9]]
I want to change the values in the array such that amounts under or over certain sizes are set to 0 i.e. a certain condition is met or not met.
e.g. in the above example I want any value which is less than 3 and any value which is greater than 7 to be changed to zero.
The changed array a should now look like this.
[[0,0,3],[4,5,6],[7,0,0]]
How do I do this in Python 3 code? One quick handicap. I don't want to use for loops. I want to do this as quickly and efficiently as possibly, possibly using numpy.
Thanks Peter
I have a relatively simple problem concerning arrays but I have read through several python training packages looking for an appropriate function without success
Here is my problem. I have an array with various values in the array. let's say
a = [[1,2,3],[4,5,6],[7,8,9]]
I want to change the values in the array such that amounts under or over certain sizes are set to 0 i.e. a certain condition is met or not met.
e.g. in the above example I want any value which is less than 3 and any value which is greater than 7 to be changed to zero.
The changed array a should now look like this.
[[0,0,3],[4,5,6],[7,0,0]]
How do I do this in Python 3 code? One quick handicap. I don't want to use for loops. I want to do this as quickly and efficiently as possibly, possibly using numpy.
Thanks Peter