I am trying to get for every row containing NaN values, all the indices of the corresponding columns.
d=[[11.4,1.3,2.0, NaN],[11.4,1.3,NaN, NaN],[11.4,1.3,2.8, 0.7],[NaN,NaN,2.8, 0.7]] df = pd.DataFrame(data=d, columns=['A','B','C','D']) print df ABCD 0 11.4 1.3 2.0 NaN 1 11.4 1.3 NaN NaN 2 11.4 1.3 2.8 0.7 3 NaN NaN 2.8 0.7
I have already done the following:
- add a column with a NaN score for each row
- get indices of each row containing NaN values
What I want (ideally, the column name) gets a list like this:
[ ['D'],['C','D'],['A','B'] ]
Hope I can find a way without doing a test for each column for each row
if df.ix[i][column] == NaN:
I am looking for a pandas way to be able to handle my huge dataset.
Thanks in advance.