Home > OS >  Filtering a pandas dataframe/logical operators
Filtering a pandas dataframe/logical operators

Time:10-15

I have a dataframe that I am needing to filter, but I'm not quite sure how. I need to create a new dataframe where I have retrieved all the rows where the number of helpful_votes divided by total_votes columns is equal to or greater than 50%. Can anyone help me with the code for this?

Here is the dataframe I am filtering

CodePudding user response:

you maybe can do that

df = df[(df['helpful_votes']/df['total_votes']) > 0.5]
  • Related