相关疑难解决方法(0)

Pandas DataFrame样式HTML显示没有索引?

我有一个pandas数据帧,我正在使用df.style对象使其突出显示奇数行,所以:

def highlight_oddRow(s):
    return ['background-color: yellow' if s.name % 2 else '' for v in s]

table = pd.DataFrame(
    {'a': [3,9,8,0,2], 'b': [5,95, 9, 25,5], 'c': [23,54, 2, 3,5], 'row': [1, 2, 3, 4, 5]})

with open ('out.html','w') as out:
    print >> out, table.style.apply(highlight_oddRow, axis=1).render()
Run Code Online (Sandbox Code Playgroud)

但是,这总是打印出索引.有没有办法告诉它不要这样做?

html pandas

3
推荐指数
3
解决办法
5230
查看次数

标签 统计

html ×1

pandas ×1