<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>scipy.sparse.csc_matrix.nonzero — SciPy v1.1.0.dev0+4e64658 Reference Guide</title> <link rel="stylesheet" type="text/css" href="../_static/css/spc-bootstrap.css"> <link rel="stylesheet" type="text/css" href="../_static/css/spc-extend.css"> <link rel="stylesheet" href="../_static/scipy.css" type="text/css" > <link rel="stylesheet" href="../_static/pygments.css" type="text/css" > <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '1.1.0.dev0+4e64658', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: false }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/scipy-mathjax/MathJax.js?config=scipy-mathjax"></script> <script type="text/javascript" src="../_static/js/copybutton.js"></script> <link rel="index" title="Index" href="../genindex.html" > <link rel="search" title="Search" href="../search.html" > <link rel="top" title="SciPy v1.1.0.dev0+4e64658 Reference Guide" href="../index.html" > <link rel="up" title="scipy.sparse.csc_matrix" href="scipy.sparse.csc_matrix.html" > <link rel="next" title="scipy.sparse.csc_matrix.power" href="scipy.sparse.csc_matrix.power.html" > <link rel="prev" title="scipy.sparse.csc_matrix.multiply" href="scipy.sparse.csc_matrix.multiply.html" > </head> <body> <div class="container"> <div class="header"> </div> </div> <div class="container"> <div class="main"> <div class="row-fluid"> <div class="span12"> <div class="spc-navbar"> <ul class="nav nav-pills pull-left"> <li class="active"><a href="../index.html">SciPy v1.1.0.dev0+4e64658 Reference Guide</a></li> <li class="active"><a href="../sparse.html" >Sparse matrices (<code class="docutils literal"><span class="pre">scipy.sparse</span></code>)</a></li> <li class="active"><a href="scipy.sparse.csc_matrix.html" accesskey="U">scipy.sparse.csc_matrix</a></li> </ul> <ul class="nav nav-pills pull-right"> <li class="active"> <a href="../genindex.html" title="General Index" accesskey="I">index</a> </li> <li class="active"> <a href="../py-modindex.html" title="Python Module Index" >modules</a> </li> <li class="active"> <a href="scipy.sparse.csc_matrix.power.html" title="scipy.sparse.csc_matrix.power" accesskey="N">next</a> </li> <li class="active"> <a href="scipy.sparse.csc_matrix.multiply.html" title="scipy.sparse.csc_matrix.multiply" accesskey="P">previous</a> </li> </ul> </div> </div> </div> <div class="row-fluid"> <div class="spc-rightsidebar span3"> <div class="sphinxsidebarwrapper"> <p class="logo"><a href="../index.html"> <img class="logo" src="../_static/scipyshiny_small.png" alt="Logo"> </a></p> <h4>Previous topic</h4> <p class="topless"><a href="scipy.sparse.csc_matrix.multiply.html" title="previous chapter">scipy.sparse.csc_matrix.multiply</a></p> <h4>Next topic</h4> <p class="topless"><a href="scipy.sparse.csc_matrix.power.html" title="next chapter">scipy.sparse.csc_matrix.power</a></p> </div> </div> <div class="span9"> <div class="bodywrapper"> <div class="body" id="spc-section-body"> <div class="section" id="scipy-sparse-csc-matrix-nonzero"> <h1>scipy.sparse.csc_matrix.nonzero<a class="headerlink" href="#scipy-sparse-csc-matrix-nonzero" title="Permalink to this headline">¶</a></h1> <dl class="method"> <dt id="scipy.sparse.csc_matrix.nonzero"> <code class="descclassname">csc_matrix.</code><code class="descname">nonzero</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/scipy/scipy/blob/4e64658/scipy/sparse/csc.py#L172-L193"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#scipy.sparse.csc_matrix.nonzero" title="Permalink to this definition">¶</a></dt> <dd><p>nonzero indices</p> <p>Returns a tuple of arrays (row,col) containing the indices of the non-zero elements of the matrix.</p> <p class="rubric">Examples</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">scipy.sparse</span> <span class="k">import</span> <span class="n">csr_matrix</span> <span class="gp">>>> </span><span class="n">A</span> <span class="o">=</span> <span class="n">csr_matrix</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">0</span><span class="p">],[</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">4</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">5</span><span class="p">]])</span> <span class="gp">>>> </span><span class="n">A</span><span class="o">.</span><span class="n">nonzero</span><span class="p">()</span> <span class="go">(array([0, 0, 1, 2, 2]), array([0, 1, 2, 0, 2]))</span> </pre></div> </div> </dd></dl> </div> </div> </div> </div> </div> </div> </div> <div class="container container-navbar-bottom"> <div class="spc-navbar"> </div> </div> <div class="container"> <div class="footer"> <div class="row-fluid"> <ul class="inline pull-left"> <li> © Copyright 2008-2016, The Scipy community. </li> <li> Last updated on Sep 21, 2017. </li> <li> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.6.3. </li> </ul> </div> </div> </div> </body> </html>