I have a data frame that looks something like this:
NUM A B C D E F
p1 NaN -1.183 NaN NaN NaN 1.829711
p5 NaN NaN NaN NaN 1.267 -1.552721
p9 1.138 NaN NaN -1.179 NaN 1.227306
There is always a non-NaN value in: column F and at least one other column A-E.
I want to create a sub-table containing only those rows which contain certain combinations of non-NaN values in columns. There are a number of these desired combinations including doublets and triplets. Here are examples of three such combinations I want to pull:
- Rows which contain non-NaN values in columns A & B
- Rows which contain non-NaN values in C & D
- Rows which contain non-NaN values in A & B & C
I already know about the np.isfinite and pd.notnull commands from this question but I do not know how to apply them to combinations of columns.
Also, once I have a list of commands for removing rows that do not match one of my desired combinations, I do not know how to tell Pandas to remove rows ONLY if they do not match any of the desired combinations.