python - 在数组中查找特定值

标签 python arrays numpy

我正在尝试将数组中的条件值插入到空数组的确切位置。

empty_array = np.zeros([40,100])
for x in range (1,24):
    array[x,:,:] #which is also sized 40x100
    if the_values_in_the_array < 0.25:
         the_values_in_the_array = 0
    empty_array = empty_array + array [x,:,:]

我应该为这个逻辑使用哪种语法?我应该如何扫描 the_values_in_the_array 以找到条件值?

最佳答案

empty_array = np.zeros([40,100])
array = np.random.rand(24,40,100)

array[array<0.25]=0 # change all the values which is <0.25 to 0
for x in range(1,24):
    empty_array += array[x,:,:]

关于python - 在数组中查找特定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37834397/

相关文章:

python - python中的动态内存分配

python - 过滤多年的 Pandas

python - 通过 ssh 从远程 Linux 机器运行本地 python 脚本

python - 使用通配符删除redis中的哈希属性

python - 如何像 FFMPEG 一样在 Python 中从音频文件创建频谱图?

"False"值的 php array_filter

c++ - 函数原型(prototype)和数组参数

Java编写png文件使一切透明

Python - 跨 CSV 中多列的 Numpy 搜索

python - 使用 Cython 定义自定义 pandas 聚合函数