久久久久久久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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 综合另类 | 亚洲免费在线 | 欧美电影免费观看高清 | 欧美在线视频一区二区 | 日韩在线大片 | 欧美a在线看 | 精品人伦一区二区三区蜜桃网站 | 日韩欧美三区 | 日韩精品成人av | 中文字幕在线一区 | 国产69精品久久久久777 | 天堂精品视频 | 久久精品欧美一区二区三区麻豆 | 欧美一级在线 | 国产精品99久久久久久宅男 | 久久久久国产一区二区三区 | 久久久青草婷婷精品综合日韩 | 午夜在线影院 | 在线欧美亚洲 | 国产欧美日韩综合精品一 | 99精品在线免费观看 | 精品国产一区二区三区性色av | 丁香色婷婷 | 日韩成人精品视频 | 国产一区精品 | 久久99精品久久久久久国产越南 | 亚洲精品成人在线 | 99在线免费观看视频 | 在线免费观看黄a | 国产成人免费视频 | 久久久成人网 | 久久久久久久国产精品影院 | 成人免费网站www网站高清 | 亚洲精品久久久久avwww潮水 | 老司机狠狠爱 | 久久久久久免费精品一区二区三区 | 亚洲一区网站 | 日本不卡一区 | 中文字幕av一区二区三区 | 亚洲人成人一区二区在线观看 | 国产精品久久亚洲7777 |