applymap
is executed on each cell. You don't need to loop over each row if using this. However, it seems you are trying to highlight the entire row, so you likely want apply
by row. Using this method, you have to return an array with the same size as each row.
def expired(val):
return ['background-color: green' if val['Expiration Date'] else ''] * len(val)
new = df.style.apply(expired, axis=1)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…