I have tested a simple loop which doesn't work... If the "selected_cate" input is in the dictionnary values CATE.values(), it is supposed to print a messsage saying that it worked and add it in the global dataframe (column categ) data.categ[index]. When I give an input which is clearly in the dictionnary, it still doesn't work while the line tried alone work for the true statement !! (see the picture).
(in the test line "LIBELLE" replaces "lib" in the code, it is only a simple string)
for i in data.index:
pd.options.mode.chained_assignment = None # default='warn'
lib=data.libelle[i]
if data.categ[i]=='AUTRE':
while True:
selected_cate=input("___# " + lib + " #___ "+" va dans quelle catégorie ? ").upper()
if selected_cate in CATES.values() is True:
print("Dictionnary CATES contains selected_case")
data.categ[i]= selected_cate
break
else:
print("erreur : catégorie non reconnue")