np.zeros
#int type n rows m columns
l_2d = np.zeros((n,m), dtype=int)
# index:[0,1]
# l_2d:[[0, 0, 0], [0, 0, 0]]
for index in indices:
l_2d[index[0],:] += 1
l_2d[:,index[1]] += 1
print(l_2d)
l_2d = np.zeros((n,m), dtype=int)
print(l_2d % 2 != 0)
np.count_nonzero(l_2d % 2 != 0)
Recommended Posts