Getting (index, column) pairs for True elements of a boolean DataFrame in Pandas
My approach uses MultiIndex
:
#make it a multi-indexed Series
stacked = y.stack()
#restrict to where it's True
true_stacked = stacked[stacked]
#get index as a list of tuples
result = true_stacked.index.tolist()
x[x > 0].stack().index.tolist()