Is there any function to check if a value exists in any rows of any columns in pandas, such as
columnA columnB columnC
"john" 3 True
"mike" 1 False
"bob" 0 False
on the dataframe above, I want to know if there are any values named "mike"
in any elements of the whole dataframe, and if it exists, I'd like to get True
- otherwise get False
.
Thanks.
Something like this:
df.apply(lambda x: 'mike' in x.values, axis=1).any()
or
df.applymap(lambda x: x == 'mike').any().any()
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