I have a very large dataset (roughly 200000×400), however I have it filtered and only a few hundred values remain, the rest are NaN. I would like to create a list of indexes of those remaining values. I can't seem to find a simple enough solution.
0 1 2
0 NaN NaN 1.2
1 NaN NaN NaN
2 NaN 1.1 NaN
3 NaN NaN NaN
4 1.4 NaN 1.01
For instance, I would like a list of [(0,2), (2,1), (4,0), (4,2)].
Best Answer
Convert the dataframe to it's equivalent
NumPy
array representation and check forNaNs
present. Later, take the negation of it's corresponding indices (indicating non nulls) usingnumpy.argwhere
. Since the output required must be a list of tuples, you could then make use of generatormap
function applyingtuple
as function to every iterable of the resulting array.