I have a dataframe with one column(dtype=bool) contains True
/False
values, I want to filter the records if bool column == False
Below script gives error, please help.
if mFile['CCK'].str.contains(['False']):
print(mFile.loc[mFile['CCK'] == False])
Error in
if mFile['CCK'].str.contains(['False']
You don't need to convert the value to a string (str.contains
) because it's already a boolean. In fact, since it's a boolean, if you want to keep only the true values, all you need is:
mFile[mFile["CCK"]]
Assuming mFile is a dataframe and CCK only contains True and False values
Edit: If you want false values use:
mFile[~mFile["CCK"]]
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