hello I need help to drop some rows by the condition: if the estimated price minus price is more than 1500 (positive) drop the row
price estimated price
0 13295 13795
1 19990 22275
2 7295 6498
for example only the index 1 would be drop thank you!
You can use pd.drop() in which you can drop specific rows by index. :
>>> df.drop(df[(df['estimated price']-df['price'] >= 1500)].index)
price estimated price
0 13295 13795
2 7295 6498
index 1 is dropped.
Note that this method assumes that your index is unique. If otherwise, boolean indexing is the better solution.
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