Fastest way to zero out low values in array?

后端 未结 9 1568
忘掉有多难
忘掉有多难 2020-12-24 07:07

So, lets say I have 100,000 float arrays with 100 elements each. I need the highest X number of values, BUT only if they are greater than Y. Any element not matching this

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-24 07:42

    You can use map and lambda, it should be fast enough.

    new_array = map(lambda x: x if x>y else 0, array)
    

提交回复
热议问题