当前位置:网站首页>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()
边栏推荐
- 200 yuan a hair dryer, only a week, to achieve 2million?
- Jmeter之用户自定义变量和抽离公共变量
- 阿明的告白
- Research on text classification of e-commerce comments based on mffmb
- Super super super realistic digital people! Keep you on the air 24 hours a day
- Master MySQL in an article
- 8 tips to adjust database performance optimization, yyds
- Day06 MySQL knowledge points summary
- Tensorflow 2 detailed explanation (TF ecosystem, installation, housekeeping, basic operation)
- D3D计算着色器入门
猜你喜欢

微波炉整流二极管 CL01-12

OAuth2和JWT

Hnoi2012 mine construction

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

C#从入门到精通(三)

使用 SAP UI5 FileUploader 控件上传本地文件试读版

Research on the integrated data quality management system and technical framework under the scenario of data circulation and transaction

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

JDBC实现MySQL8.0数据库的增删改查

Verilog语法基础HDL Bits训练 06
随机推荐
Research on the influence of opinion leaders based on network analysis and text mining
测试左移和测试右移的概念
pip install --upgrade can‘t find Rust compiler
How to open the Internet and ask friends to play together?
参数解析器HandlerMethodArgumentResolver分析与实战
Biological JC uvssa complex alleviates myc driven transcription pressure ⼒ English
Solve the problem that when the background image is set to be 100% full, when the horizontal scroll bar appears in the zoom browser, the part of the background image beyond the scroll bar is not full
Redis(八) - Redis企业实战之优惠券秒杀
Use localdate class to complete calendar design
Jmeter之用户自定义变量和抽离公共变量
Force deduction record: Sword finger offer (2) -- jz13-22
[zero based BLDC series] brushless DC motor control principle based on the zero crossing detection method of back EMF
Hnoi2012 mine construction
Day06 MySQL knowledge points summary
With data-driven management transformation, the first year of science and technology was at the right time
Unityvr -- robot arm scene 4- gifts and Christmas tree
Leetcode 笔记 350. 两个数组的交集 II
Modeling and simulation analysis of online medical crowdfunding communication based on SEIR model
开放下载!《阿里巴巴 DevOps 实践手册》
200 yuan a hair dryer, only a week, to achieve 2million?