【发布时间】:2016-09-11 10:11:38
【问题描述】:
我想告诉你数组的索引列在哪里不一样。
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)
示例:
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.]
我想要输出:
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
【问题讨论】:
标签: python arrays python-2.7 numpy