这是我的数据框——
c2_name Q1_GMV Q2_GMV growth(%)
0 A 1170727260 221801763 -81
1 B 1604716749 829186592 -48
2 C 661473481 553698141 -16
我正在尝试使用 pandas 样式将 CSS 添加到数据框输出中。
# Set colormap equal to seaborns light green color palette
cm = sns.light_palette("green", as_cmap=True)
(df.style
.background_gradient(cmap=cm, subset=['growth(%)'])
.set_caption('This is a custom caption.')
.set_table_styles(styles))
但是得到这个错误
TypeError: ("unsupported operand type(s) for -: 'decimal.Decimal' and 'float'", 'occurred at index growth(%)')
试图让它看起来像这样