find 和 np.where
来源:互联网 发布:qq三国79js 79xs 编辑:程序博客网 时间:2024/06/03 15:58
1. matlab中的find函数
将数组中的偶数值返回:
- 1
- 2
- 1
- 2
matlab中find的函数的强大之处在于其能返回下标,且视返回参数的个数,返回以列全排序的一维下标(返回参数的个数为1),返回行列索引的二维坐标(返回参数的个数为2):
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
2. python:遍历+判断
- 1
- 2
- 3
- 4
- 5
- 6
- 1
- 2
- 3
- 4
- 5
- 6
3. python numpy:np.where
Python
或者numpy
中能够返回符合某一条件的下标的函数是np.where()
,不过np.where()
并不接受list
类型的参数,可见np.where()
既可以接收三个参数,用于三目运算,也可接收一个参数,返回符合条件的下标。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
注意,这种情况下,也即 np.where() 用于返回断言成立时的索引,返回值的形式为 arrays of tuple,由 np.array 构成的 tuple,一般 tuple 的 len 为2(当判断的对象是多维数组时),哪怕是一维数组返回的仍是 tuple,此时tuple 的 len 为 1;
- np.where()[0] 表示行的索引,
- np.where()[1] 则表示列的索引
np.where()
用于三目运算的情况:
- 1
- 2
- 3
- 4
- 1
- 2
- 3
- 4
4. 处理NaN(not a number)
将nan所在的列非nan的均值赋给这些nan值
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
阅读全文
0 0
- find 和 np.where
- np.where和np.bincount详解
- np.where
- Python vs Matlab—— find 与 np.where
- numpy 之 np.where
- np.where函数
- python np.where()
- numpy: np.where
- python np.where
- [python]关于np.where与np.in1d合用
- NP-Hard 和 NP-Complete
- np.tile 和np.newaxis
- np.ravel()和np.flatten()
- Ruby on Rails 查询数据库 where 和 find 的区别
- Where to Find What?
- mongoose $where、find查询
- 什么是NP问题,NP-complete和NP-hard问题.
- 什么是NP问题,NP-complete和NP-hard问题.
- mysql插入中文报错
- 创建安卓app的30个经验教训
- linux命令-tar
- 来自看雪的手把手调试DebugPort清零
- Unity3D 热更新方案
- find 和 np.where
- 51nod1799 二分答案
- 对《我的管家》项目进行整理
- studio和Eclipse分别生成jar包并混淆jar包
- Intellij IDEA 实用技巧
- Pycharm和Anaconda中如何安装package
- c#事件
- 如何设置微信小程序编译时的启动页?
- Java 通过HttpClient 带证书方式请求Https协议网站 (Post方式带xml文档,Get以及Delete方式)