python - python) 我只想从相关表中提取大于 0.9 的值
问题描述
我的相关表由 1446 x 1447 组成。
其中,我只想看到大于 0.9 的数字。(包括 0.9)
解决方案
您可以使用numpy.where
with 条件来查找满足条件的索引或实际值。
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)
推荐阅读
- scala - Spark 2.2.0 - 如何从 EC2 列出 S3 存储桶中的文件
- firebase - Firebase 控制台读取成本
- html - 修复了 Div 在整个屏幕上的拉伸,需要每个占据 % 的水平空间
- apache-spark - Spark 数据框 na.fill 布尔列类型
- sql - 如何在 db2 过程中锁定多条记录?
- django - Django Rest Framework 中权限/过滤器的最佳实践
- sql - 每个表中的外连接和唯一记录
- php - 是否有一种简化的方法来检查字符串数组的每个索引?
- botframework - 如何从会话对象中获取当前库名称
- android - 使用 Square 的 Wire 时出现 D8 异常