Quantcast
Channel: pythonic way to get index,column for value == 1 - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by dlask for pythonic way to get index,column for value == 1

$
0
0
>>> import numpy>>> a = numpy.array([[1, 0, 1], [0, 1, 1], [0, 1, 0]])>>> numpy.transpose(numpy.nonzero(a))array([[0, 0],       [0, 2],       [1, 1],       [1, 2],       [2, 1]])

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>