久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

用 pandas 為excel中的單元格著色

coloring cells in excel with pandas(用 pandas 為excel中的單元格著色)
本文介紹了用 pandas 為excel中的單元格著色的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我需要一些幫助.所以我有這樣的東西

I need some help here. So i have something like this

import pandas as pd
path = '/Users/arronteb/Desktop/excel/ejemplo.xlsx'
xlsx = pd.ExcelFile(path)
df = pd.read_excel(xlsx,'Sheet1')
df['is_duplicated'] = df.duplicated('#CSR')
df_nodup = df.loc[df['is_duplicated'] == False]
df_nodup.to_excel('ejemplo.xlsx', encoding='utf-8')

所以基本上這個程序將 ejemlo.xlsx (ejemlo 是西班牙語的例子,只是文件名)加載到 df (一個 DataFrame),然后檢查特定列中的重復值 .它會刪除重復項并再次保存文件.那部分工作正常.問題是,我需要用不同的顏色(如黃色)突出顯示包含重復項的單元格,而不是刪除重復項.

So basically this program load the ejemplo.xlsx (ejemplo is example in Spanish, just the name of the file) into df (a DataFrame), then checks for duplicate values in a specific column??. It deletes the duplicates and saves the file again. That part works correctly. The problem is that instead of removing duplicates, I need highlight the cells containing them with a different color, like yellow.

推薦答案

你可以創建一個函數來做高亮...

You can create a function to do the highlighting...

def highlight_cells():
    # provide your criteria for highlighting the cells here
    return ['background-color: yellow']

然后將突出顯示功能應用于您的數據框...

And then apply your highlighting function to your dataframe...

df.style.apply(highlight_cells)

這篇關于用 pandas 為excel中的單元格著色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 国产成人啪免费观看软件 | 99精品国产在热久久 | 日韩精品一区二区三区中文在线 | 欧美不卡视频一区发布 | 中文成人在线 | 欧美国产中文 | 亚洲欧美日韩精品久久亚洲区 | 精国产品一区二区三区 | 91久久久久| 国产成人在线免费 | 欧美色综合| 日韩国产一区二区三区 | 国产精品久久久久久久久 | 高清色 | 国产福利资源在线 | 国产精品www| 国产日韩一区二区三免费高清 | 成人在线免费观看 | 国产精品视频网址 | 中文字幕免费在线 | 久久国产精品视频 | 美女中文字幕视频 | 在线婷婷| 黄色免费在线观看网站 | 免费黄色av | 一级毛片免费看 | 有码一区 | 二区三区av | 成人在线免费观看av | 亚洲一区二区精品视频在线观看 | 免费看a | 91久久精品日日躁夜夜躁欧美 | 国产一区二区三区久久久久久久久 | a黄视频| 毛片网站在线观看视频 | 亚洲国产成人av好男人在线观看 | 日韩精品一区二区三区在线播放 | 日日夜精品视频 | 精品国产乱码久久久久久a丨 | 亚洲一区二区在线播放 | 国产一区二区三区免费观看在线 |