Quantcast
Channel: pythonic way to get index,column for value == 1 - Stack Overflow
Browsing latest articles
Browse All 2 View Live

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

>>> 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]])

View Article


pythonic way to get index,column for value == 1

I currently have a MxN dataframe which contains a solution to an optimization problem. "Active" i,j for i in {M} and j in {N} pairs are represented by 1 and "inactive" pairs by 0. I need to determine...

View Article
Browsing latest articles
Browse All 2 View Live