尝试将此样式器对象转换为xlsx表:
avg.style.background_gradient(cmap='RdYlGn',low=.09,high=.18,axis=1).to_excel('test.xlsx',engine='xlsxwriter')
然而,我收到错误:
TypeError: MetaSerialisable object argument after ** must be a mapping, not unicode
当我尝试时:
avg.style.background_gradient({'cmap':'RdYlGn'},low=.09,high=.18,axis=1).to_excel('test.xlsx',engine='xlsxwriter')
TypeError: ("unhashable type: 'dict'", u'occurred at index (Gain/Expsr%, 5)')
这里有一个,没有背景渐变输出:
writer = pd.ExcelWriter('usher.xlsx')
df.style.background_gradient(cmap='RdYlGn').to_excel(writer,engine='openpyxl')
writer.save()