How do I drop a row if any of the values in the row equal zero?
I would normally use df.dropna() for NaN values but not sure how to do it with "0" values.
Use pandas. DataFrame. drop() method to delete/remove rows with condition(s).
You can use the Filter function to filter out all rows based on the zero values in a certain column, and then delete all visible rows later. Please do as follows. 1. Select the column cells which contain the zero values you want to delete the entire rows based on, then click Data > Filter.
One of the fastest ways to delete rows that contain a specific value or fulfill a given condition is to filter these. Once you have the filtered data, you can delete all these rows (while the remaining rows remain intact).
i think the easiest way is looking at rows where all values are not equal to 0:
df[(df != 0).all(1)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With