在python的numpy里面这个函数的意义是返回参数数组中不为0的元素的索引(indics)。
from numpy import array
 from numpy import nonzero
x=array([[1,0,0], [0,2,0], [1,1,0]])
print(x)
nonzero(x)
output:
[[1 0 0] [0 2 0] [1 1 0]] (array([0, 1, 2, 2], dtype=int64), array([0, 1, 0, 1], dtype=int64))
这个是要把两行捏在一起来看:
[0,1,2,2]
[0,1,0,1]
代表作为二维数组[0,0],[1,1],[2,0],[2,1]四个位置的元素不为0,也就说返回的一个数组是行信息,第二个数组对应的列信息,组合在一起就是一个(x,y)坐标。

nonzero的更多相关文章

  1. Android Stduio 发生 Process 'command 'somePath:java.exe'' finished with non-zero exit value 2 异常的解决办法

    有时你会发现,在你使用Android Studio 进行编译的时候提示: Error:Execution failed for task ':demo:dexDebug'.> com.andro ...

  2. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command ' finished with non-zero exit value 1

    Error:Execution failed for task ':lenovoAlbum:processReleaseResources'. > com.android.ide.common. ...

  3. Last non-zero Digit in N!(阶乘最后非0位)

    Last non-zero Digit in N! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Jav ...

  4. [转]finished with non-zero exit value 2

    Error:Execution failed for task ':phoneacompany:dexDebug'. > com.android.ide.common.process.Proce ...

  5. Android Studio编译运行project报错:····· finished with non-zero exit value 1

    错误代码: Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.ide.c ...

  6. finished with non-zero exit 添加v7包报错的问题

    错误: 添加 compile 'com.android.support:appcompat-v7:22.2.0'后报错,里面有其它的jar包,但是只要添加这个v7包就报错. Error:Executi ...

  7. dexDebug ExecException finished with non-zero exit value 2

    Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transf ...

  8. 【转】Python numpy库的nonzero函数用法

    当使用布尔数组直接作为下标对象或者元组下标对象中有布尔数组时,都相当于用nonzero()将布尔数组转换成一组整数数组,然后使用整数数组进行下标运算. nonzeros(a) 返回数组a中值不为零的元 ...

  9. Last non-zero Digit in N!

    Problem Description The expression N!, read as "N factorial," denotes the product of the f ...

  10. shark错误:Query returned non-zero code: -101

      环境:shark(0.11分支编译)+spark 0.8+hive 0.11(编译)+hadoop 2.00 cdh4.4 用sharkserver的方式执行一段时间后,通过kit-b8连接到ki ...

随机推荐

  1. L251

    Beer before wine, or wine before beer; whatever the order, you’ll feel queer. That, at least, is the ...

  2. UIIimageView读取图片的两种方式及动画的执行

    /**count:图片数量 name:图片名称*/ - (void)runAnimationWithCount:(int)count name:(NSString *)name { if(self.t ...

  3. python Django rest-framework 创建序列化工程步骤

    11创建项目 2创建应用 3stting添加应用(apps)-添加制定数据库-修改显示汉字(zh-hans)-上海时区(Asia/Shanghai) 4主路由添加子路由 5应用里创建子路由 6创建数据 ...

  4. mybatis Condition查询

    Condition condition = new Condition(ACurrentTotal.class); condition.createCriteria().andCondition(&q ...

  5. Js代码一些要素

    ---恢复内容开始--- 条件语句 is(条件){ 语句 }else { 语句 } {}在js中我们把他叫代码块.如果代码块里内容没有执行完,语句就不会向下执行. 代码块是一个独立的整体.如果js中莫 ...

  6. Centos7虚拟机下配置静态IP

    以下为Centos7在VMware下配置静态IP地址,配置完后内外网都可以访问,主机与虚拟机之间可以通信. 1.在VMware里,菜单栏点击[编辑]-->[虚拟网络编辑器],如下图.选择的是NA ...

  7. 【转载】 A* 寻路算法 (个人认为最详细,最通俗易懂的一个版本)

    原文地址: http://www.cppblog.com/christanxw/archive/2006/04/07/5126.html =============================== ...

  8. Spring Cloud 微服务实战

    Eureka 服务治理 Maven dependency 与spring boot的版本的对应 Finchley兼容Spring Boot 2.0.x,不兼容Spring Boot 1.5.x Dal ...

  9. 《DSP using MATLAB》Problem 5.15

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  10. 【git】git使用

    1.创建github账户 网站:https://github.com/ 注册省略 2.ssk-key客户端配置 作用:不用每次push,clone代码不需要输入用户名+密码 生成ssh-key ssh ...