def first_true1(a):
    """ return a dict of row: index with value in row > 0 """
di = {}
for i in range(len(a)):
    idx = np.where(a[i] > 0)
try:
    di[i] = idx[0][0]
except IndexError:
    di[i] = None
return di
Finding first non-zero value along axis of a sorted two dimensional numpy array