首页 > 解决方案 > python) 我只想从相关表中提取大于 0.9 的值

问题描述

我的相关表由 1446 x 1447 组成。

其中,我只想看到大于 0.9 的数字。(包括 0.9)

标签: pythonfilteringcorrelation

解决方案


您可以使用numpy.wherewith 条件来查找满足条件的索引或实际值。

import numpy as np
table = np.random.rand(1446, 1447)
# get all indexes of elem having value >= 0.9
filtered_idx = np.where(table >= 0.9)
# get all elem values >= 0.9
filtered_values = table[filtered_idx]
assert all(filtered_values >= 0.9)

推荐阅读