我正在使用dataframe style.map函数根据一些条件为我的表格单元着色,使用下面的代码
def color(s):
for i in range (1,12):
if s.iloc[i]<s.iloc[0]:
return 'color: green'
else:
return 'color: red'
df3.style.apply(color,axis=1)
但我收到了错误
AttributeError: 'Series' object has no attribute 'iterrows'
我觉得我的语法是正确的,如果我在函数内部打印了一些内容,那么它就会打印出来,之后会出现这个错误。 为什么我收到这个错误?