应用style.map函数时出错

时间:2016-11-22 18:56:01

标签: python dataframe

我正在使用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'

我觉得我的语法是正确的,如果我在函数内部打印了一些内容,那么它就会打印出来,之后会出现这个错误。 为什么我收到这个错误?

0 个答案:

没有答案