在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. MVC4实现批量更新数据

    Html: @using (Html.BeginForm("Edit", "Home")) { <div> <input type=" ...

  2. 类的无参方法和Doc注释

    一:Java Doc注释: 语法: /** *AccpSchool 类 *@author JadeBird *@version 1.0 2018/5/26 */ Java Doc是前Sun公司提供的一 ...

  3. java学习笔记23(Set接口)

    Set接口: 1.Set接口是不包含重复元素的Collection: 2.set集合没有索引,只能通过增强型for循环或迭代器来遍历: 3.Set接口只包含从collection接口继承的方法,并且增 ...

  4. python day09--定义函数

    一.函数的定义 def  函数名(参数): 函数体 来我们来定义⼀一个约x功能: def yue(): print("拿出⼿手机") print("打开陌陌") ...

  5. puppet确保程序运行

    exec { 'keep-nginx-running' : user => 'root', unless => 'ps -x | grep nginx|grep -v grep', com ...

  6. Oval框架如何校验枚举类型的一种思路

    前言: Oval校验框架被广泛集成于各类接口参数校验中, 其方便的注解语法, 易读性和扩展性. 几乎成了java后端服务代码的标配. 有人会很疑惑, 都已经是枚举类型了, 还需要校验吗? 其实这边更确 ...

  7. 【leetcode】13-Roman2Integer

    problem Roman to Integer 每个Roman表示一个数字,可以进行一一映射: 左边字符表示的数字小于右边字符时,减去对应的数字,否则加上: 注意左右字符比较时,最后一个字符不能比较 ...

  8. [LeetCode&Python] Problem 349. Intersection of Two Arrays

    Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1 ...

  9. Gym - 101806R :Recipe(分治+斜率优化)

    题意:有一个厨师,他买菜-做菜-买菜-做菜....-做菜,一共有N天,他的冰箱里只能有一个菜,在他做菜的第二天才会买菜,如果菜不做,放在冰箱里,每天新鲜程度会下降1. 第一天也会买菜,第i天的菜新鲜程 ...

  10. camp待补

    待修莫对 序列自动机 几何积分 沈阳 M 待删除背包  : 分组背包 K-LIS, K次二分(插到最后stop) 问题转化为LIS bzoj2131 hdu4055 最小线段覆盖环 实时路况 分治+f ...