I have following scenerio where I have to check for values in a column and its corresponding values in other columns. If any one of the value is not null then need to return true.
Suppose I have to check for values D, E and F in column1 and check its corresponding values in column2 and column3. Here column2 contains NaN but column3 contains data then return true
2
Answers
If I understand correctly, lets say you have the following data frame:
Then you should first set the column you want to check(Column1 in our case) as an index and do the following:
Assuming you want to test if
all
rows of the target have at least one non-NaN value (any
), use:output:
True
(but would beFalse
ifvalue1
wasNaN
)If you want to check if there is at least one non-NaN cell, use
any
in both cases:output:
True
(and would still beTrue
ifvalue1
wasNaN
)