在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. L258 技术转让

    We will inform you of the weight, measurements, number of cases, cost of the drawings and other docu ...

  2. django面试题必知

    Django的Model的继承有几种形式,分别是什么?(私信小编001 .002 .003 .007任何一个即可获取Python学习资料) 一.抽象继承: 这种继承的定义方法如下: 上例中,我们的Hu ...

  3. tp5 Excel导出

    1.百度搜索 PHPexcel (这是一个PHP类库) 2.下载的文件放到vendor里(这是tp5专门放置类库文件的) 下面是代码 /** * 导出 */ public function expor ...

  4. ORACLE中使用DBMS_RANDOM去产生随机数

    一.生成随机字符串:DBMS_RANDOM.STRING 用法:DBMS_RANDOM.STRING(选项, 返回字符串长度) 选项有如下几种可供选择:1)'u', 'U' - returning s ...

  5. ES6 函数的扩展-rest参数

    ES6 引入 rest 参数(形式为...变量名),用于获取函数的多余参数,这样就不需要使用arguments对象了.rest 参数搭配的变量是一个数组,该变量将多余的参数放入数组中. functio ...

  6. Power BI与Tableau基于Google搜索上的比较

    在数据分析领域里,不少的数据爱好者都会关心什么数据分析产品最好用?最重要的是,很多的企业也特别希望员工能真正知道如何使用这些BI平台以确保公司的投资是值得.同类的文章,小悦也曾发布过,可参考最近< ...

  7. [转]EM算法(Expectation Maximization Algorithm)详解

    https://blog.csdn.net/zhihua_oba/article/details/73776553 EM算法(Expectation Maximization Algorithm)详解 ...

  8. tmux-2.3 conf

    set-window-option -g automatic-rename off set -g allow-rename off # 把前缀键从 C-b 更改为 C-a set -g prefix ...

  9. Linux批量解压文件

    最近下载了Imagenet2012的数据文件,训练数据下有很多tar文件,这些tar文件都在一个目录内,所以想批量解压到该目录下每个单独的文件夹内 批量解压的步骤是, 1.列出所有的以tar为后缀的文 ...

  10. Gym .102021 .German Collegiate Programming Contest (GCPC 18) (寒假gym自训第三场)

    B .Battle Royale 题意:给你两个点A,B,以及一个圆S,保证两个点在圆外,且其连线与圆相交,求两点间最短距离. 思路:显然是要分别与圆相切,然后在圆弧想走,直到相交. 那么ans=与圆 ...