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
Edit : sample data : https://raw.githubusercontent.com/srpjv/data/main/name.csv
The function :
df2["Deversement Service"] = df2.swifter.apply(conditions, axis=1)
The conditions without change :
def conditions(df2):
# Services
if df2["Trigram MyPortal"] =="fr") is True return "Something"
# Autoconso
elif (df2["Trigram MyPortal"]=="Be") is True: return "* Autoconso"
elif (df2["Trigram MyPortal"]=="De") is True: return "* Autoconso DE"