I have the following function...
Is there a way i could somehow add a loop so that each value in the list gets checked. The code shows checking each index with an elif one at a time. I am just wondering if it possible to do it in a single elif block?
What i tried and didnt work:
for loop in range(0,5) and then just putting elif (str(df.iloc[i]['Name']) in x):
range(0,5) in the index argument itself elif (str(df.iloc[range(0,5)]['Name']) in x):
def colourcode(x):
if ( str('default') in x):
return '#fff034'
elif (str(df.iloc[0]['Name']) in x):
return '#ff0000'
elif (str(df.iloc[1]['Name']) in x):
return '#ff0000'
elif (str(df.iloc[2]['Name']) in x):
return '#ff0000'
else:
return '#000000'
Aucun commentaire:
Enregistrer un commentaire