numpy.where() 函数翻译
2018-03-19 16:30
288 查看
函数原型:
numpy.where(condition[,x,y]) 参数: 1. condition,判定条件,布尔数组或者布尔变量
2. x和y, 数组,非必须参数
返回值: 1. 函数参数中有数组x和数组y,当判定条件为真时,返回的数组从x中取值,否则从数组y中取值
2. 函数参数中只有判定条件,返回值为满足判定条件的元组的索引。
实例:
2. 判定条件为布尔数组:[[True, False], [True, True]],x为数组[[1, 2], [3, 4]], y为数组[[9,8], [7,6]] 。
3. 当为True时,取x中的值,为False时,取y中的值,返回的数组[[1, 8],[3, 4]]。
1. 函数参数列表中只有判定条件
2. 判定条件为 x>5,返回满足判定条件元组的索引: [2,0], [2, 1], [2, 2],指向的元素分别为[6,7,8]
源自:http://https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html
numpy.where(condition[,x,y]) 参数: 1. condition,判定条件,布尔数组或者布尔变量
2. x和y, 数组,非必须参数
返回值: 1. 函数参数中有数组x和数组y,当判定条件为真时,返回的数组从x中取值,否则从数组y中取值
2. 函数参数中只有判定条件,返回值为满足判定条件的元组的索引。
实例:
>>> np.where([[True, False], [True, True]], ... [[1, 2], [3, 4]], ... [[9, 8], [7, 6]]) array([[1, 8], [3, 4]]) >>>1. 函数参数列表中有判定条件,数组x和y
2. 判定条件为布尔数组:[[True, False], [True, True]],x为数组[[1, 2], [3, 4]], y为数组[[9,8], [7,6]] 。
3. 当为True时,取x中的值,为False时,取y中的值,返回的数组[[1, 8],[3, 4]]。
>>> x = np.arange(9.0).reshape(3, 3) >>> x array([[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]]) >>> np.where(x>5) (array([2, 2, 2], dtype=int64), array([0, 1, 2], dtype=int64)) >>>
1. 函数参数列表中只有判定条件
2. 判定条件为 x>5,返回满足判定条件元组的索引: [2,0], [2, 1], [2, 2],指向的元素分别为[6,7,8]
源自:http://https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html
相关文章推荐
- Faster-R-CNN(Python).3: numpy.where()函数
- numpy中的where()函数
- Python中numpy的where()函数
- numpy.where()函数 返回值的解释
- Python中numpy的where()函数
- numpy.where()函数
- Faster-R-CNN(Python).3: numpy.where()函数
- 学习Python数据分析随手笔记【一】numpy数组的函数简单应用
- python中numpy对函数进行矢量化转换
- C#中使用网络函数 (第一部分 用户函数)[翻译]
- 对numpy中的where方法嵌套使用详解
- Python调用C++函数(SWIG,VS2013使用numpy.i完成Numpy与C++数组转换)
- PHP OPENSSL 函数手册翻译备查 -- openssl_cipher_iv_length
- 在 SQL Server 2K 中实现 大小写敏感的查询条件(WHERE ...),类似 Access(VB) 的 StrComp 函数
- xdebug所有相关方法函数详解(中文翻译版)
- numpy使用过程中小函数记录
- python: numpy--函数 shape用法
- numpy教程 - 多维数组ndarray的创建、属性、内建函数及运算
- LoadRunner函数中文翻译系列之一--Action(转帖)
- python numpy.tile函数