Let's assume I have the following DataFrame:
book | page | words_per_page | characters |
---|---|---|---|
Book 1 | 1 | 27 | Nan |
Book 1 | 2 | Nan | 30 |
Book 1 | 2 | 30 | 25 |
Book 2 | 1 | 30 | 26 |
Book 2 | 2 | 28 | 30 |
How can I delete the books containing at least one null value for either Words Per Page
or Characters
? In the above situation, I want to drop all the entries associated with Book 1.
It is a combination between these two questions, but I just couldn't get it right yet.
pandas How to drop the whole row if any specific columns contains a specific values?
How to delete rows from a dataframe if specific columns contains null values?
It should be a way to do it directly on the dataframe. I have lots of data and I need to make this run as efficiently as possible, I'm trying to avoid if
statements outside of the dataframe.
Thanks everyone!