python np.where()
来源:互联网 发布:js缺少对象 编辑:程序博客网 时间:2024/06/11 23:28
numpy.where()函数是三元表达式x if condition else y的矢量化版本。假设我们有一个布尔数组和两个值数组:
x = np.array([1.1, 1.2, 1.3, 1.4, 1.5])y = np.array([2.1, 2.2, 2.3, 2.4, 2.5])condition = np.array([True, False, True, True, False])假设我们想要根据condition中的值选取x和y的值:当condition中的值为True时,选取x的值,否则从y中选取。
result = np.where(condition, x, y)打印的结果为:【1.1, 2.2, 1.3, 1.4, 2.5】
阅读全文
1 0
- python np.where()
- python np.where
- [python]关于np.where与np.in1d合用
- np.where
- Python vs Matlab—— find 与 np.where
- numpy 之 np.where
- np.where函数
- find 和 np.where
- numpy: np.where
- np.where和np.bincount详解
- Python Tricks(一)—— np.where 与最大最小截断
- Python数据分析(八)-xrange,range,arange与np.where
- python pandas 如何找到NaN、缺失值或者某些元素的索引名称以及位置,np.where的使用
- Python numpy 转置、逆、去掉一列、按列取出、矩阵拼接、矩阵排序、矩阵相等、np.where,一维转二维
- python np.random.rand
- python np.log
- python np.stack()解析
- python np.newaxis
- HDU 1166 敌兵布阵(树状数组)
- 【SSH进阶之路】Hibernate基本原理(一)
- Orz教主第6次模拟赛之教主的别墅
- bootstrap开发小网页实例
- 分布式存储mogilefs
- python np.where()
- HTML-坐标的含义,以及变换的使用
- CodeArt入门教程(一)
- hdu5477-模拟-A Sweet Journey
- python常用模块(不定时更新)
- Linux字符设备驱动程序开发(3)-LED驱动程序设计
- 前端开发——HTML学习笔记
- Hive 与 Hbase的不同之处
- shell基础