How can i delete a row in a Pandas Dataframe, based on a cell value without giving a specific column name?
For example:
I have this DataFrame and i want to delete all rows where a cell contains the value 'd'.
A B C D
1 1 2 d 5
2 1 3 4 0
3 d 2 1 2
4 3 2 1 7
So I end up with the DataFrame
A B C D
2 1 3 4 0
4 3 2 1 7
Is there a way to achive this? My google skills only found solutions where a specific column name is required.
you can do it this way:
df = df[~df.select_dtypes(['object']).eq('d').any(1)]
Result:
In [23]: df
Out[23]:
A B C D
2 1 3 4 0
4 3 2 1 7
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