I'm working with Pandas. I need to create a new column in a dataframe according to conditions in other columns. I try to look for each value in a series if it contains a value (a condition to return text).This works when the values are exactly the same but not when the value is only a part of the value of the series.
if any("something") in df2["Symptom"]:
print("yes")
else:
print("no")
I got a yes, but any("something") also return a yes direcltly, it's always true without check in df2["Symptom"].
Also, .str.contains() doesn't work at all, i got the error :
Attribute error, attributeerror 'str' object has no attribute 'str'
I don't know why because df2["Symptom"] is a series.
Thanks for your help
Aucun commentaire:
Enregistrer un commentaire