To directly answer this question’s original title “How to delete rows from a pandas DataFrame based on a conditional expression” (which I understand is not necessarily the OP’s problem but could help other users coming across this question) one way to do this is to use the drop method:
Example
To remove all rows where column ‘score’ is < 50:
In place version (as pointed out in comments)
Multiple conditions
(see Boolean Indexing)
The operators are: | for or, & for and, and ~ for not. These must be grouped by using parentheses.
To remove all rows where column ‘score’ is < 50 and > 20
















