Comparing by section two numpy arrays in python and displays the index column which is not the same
<p>I want to show you where the index column of the array is not the same.</p>

<pre><code>import numpy as np
array1 = np.array(list(np.zeros(10))+list(np.ones(10)))
array2 = np.array(list(np.random.randint(2, size=10))+list(np.random.randint(2, size=10)))
matches = array1 == array2
section_sums = np.bincount(np.arange(matches.size)//10,matches)
att = int(section_sums[0])
att2 = int(section_sums[1])

print section_sums
print 'first  10 : '+ str(att)
print 'second 10 : '+ str(att2)
</code></pre>

<p>example:</p>

<pre><code>Array1:
[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  1.  1.  1.  1.  1.  1.  1.  1. 1. 1.]

Array2:
[ 0.  1.  0 . 1.  1.  1.  0.  1.  0.  1.  1.  1.  1.  0.  1.  0.  1.  1. 1. 0.]
</code></pre>

<p>I want the output:</p>

<pre><code>in section 1 index is not the same: 2,4,5,6,8,10
in section 2 index is not the same: 4,6,10
</code></pre>

<p>If you split your arrays into the two section then you can compare them.</p>

<pre><code>In [18]: a = np.array(np.split(a, [10]))

In [19]: b = np.array(np.split(b, [10]))

In [23]: ind, items = np.where(a != b)

In [25]: items[ind==0] + 1
Out[25]: array([ 2,  4,  5,  6,  8, 10])

In [26]: items[ind==1] + 1
Out[26]: array([ 4,  6, 10])
</code></pre>

python arrays python-2.7 numpy