当前位置:网站首页>Data is written into excel and filled with color
Data is written into excel and filled with color
2022-07-26 00:47:00 【Pert-】
import pandas as pd
def style_apply(content, colors, back_ground=''):
if content != None and content in colors.keys():
return 'background-color: ' + colors[content]
return back_ground
def style_color(df, colors):
return df.style.applymap(style_apply, colors=colors)
resultMap = {'A':['test1', 'test2', 'test3'], 'B':['test2', 'test4', 'test5']} # Write data structure example
filePath = "eee.xlsx"
compare_pd=pd.DataFrame(resultMap)
writer = pd.ExcelWriter(filePath, engine='openpyxl')# Create data storage path
colors = {'test1':'#ff0000', 'test2':'#ffff00'}
style_df = style_color(compare_pd, colors)
style_df.to_excel(writer, header=None, index=False, sheet_name='compare')
writer.save()# file save
writer.close()
边栏推荐
- 实战演练 | 查找在给定时间范围内购买超过 N 件商品的客户
- 【无标题】如何实现可插拔配置?
- 【oops-framework】随机数生成管理
- What is the difference between request forwarding and request redirection?
- 使用LocalDate类完成日历设计
- SQL (basic 2)
- 2022/7/24 examination summary
- Research on visualization method of technology topic map based on clustering information
- 找出单身狗(力扣260)
- DC-6--vulnhub靶场
猜你喜欢

Processes and threads

Getting started with D3D calculation shaders

SQL statement exercise

【RTOS训练营】作业讲解、队列和环形缓冲区、队列——传输数据、队列——同步任务和晚课提问

How can a team making facial mask achieve a revenue of more than 1 million a day?

【无标题】如何实现可插拔配置?

jupyter更改主界面并且导入数据集

Azure synapse analytics Performance Optimization Guide (1) -- optimize performance using ordered aggregate column storage indexes

我们没有退路了

【IJCAI 2022】参数高效的大模型稀疏训练方法,大幅减少稀疏训练所需资源
随机推荐
HCIP第十三天
Django数据库增删改查
Tell you the meaning of unit testing from another angle
Redis killed twelve questions. How many questions can you carry?
AI knows everything: build and deploy sign language recognition system from 0
Leetcode 笔记 20. 有效的括号
Day06 MySQL knowledge points summary
YOLOV3
Oauth2 and JWT
Compile openfoam solver with cmake
超全的开源Winform UI库,满足你的一切桌面开发需求!
进程与线程
P4047 [jsoi2010] tribal Division
8个小妙招调整数据库性能优化,yyds
阿明的告白
Use localdate class to complete calendar design
hcia综合实验
Test the concept of left shift and right shift
hyperf使用之curd
攻防世界web题-favorit_number