Request for help numpy array syntax
<p>I am using a template-script to learn data analysis in using numpy and I don't understand this syntax. There exist two arrays <code>dist_data</code> and <code>dataArray</code>, <code>l</code> is a loop-dummy-variable (as in <code>for l in range(0,k):</code>)and I don't understand the content, specifically the purpose of separation by <code>,</code> in the second parenthesis <code>[l, self.dataArray.shape[1]-1]</code> because I am assuming that it represented a column of <code>dist_data</code></p>

<p><code>dist_data[dist_data[:,-1].argsort()][l, self.dataArray.shape[1]-1]</code></p>

<pre><code>dist_data[dist_data[:,-1].argsort()][l, self.dataArray.shape[1]-1]
</code></pre>

<p><code>dist_data[:,-1]</code> last column of 2d <code>dist_data</code>.  Sort on that and get the indices</p>

<p>So <code>dist_data[dist_data[:,-1].argsort()]</code> is <code>dist_data</code> sorted on the last column.</p>

<p><code>[l, self.dataArray.shape[1]-1]</code> is just an indexing on a 2d array; the <code>l</code> row, and the <code>self...</code> column.  It looks like the column that corresponds to the last of <code>self.dataArray</code>.</p>

<p>So in sum - sort <code>dist_data</code> on the last column, and pick the <code>l'th</code> row, and some column.</p>

python arrays numpy