2

I cannot see what the built-in function is for the following simple but seemingly common/useful task: Drop rows which have no value for any of my key columns.

def keepIfPopulated(adf,interestingVars):
        good=0
        for vv in interestingVars:
            good+=adf[vv].notnull()
        return(adf[good>0])

If there was just one column of interest, I could choose to keep it, but most pandas functions take one or more labels as arguments, so this question is about how to check on one or more columns at once.

1 Answer 1

3
adf = adf.dropna(subset=interestingVars, how='all')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.