2021年4月8日星期四

Top/Bottom Rule Conditional Formatting in Python like Excel

I'm very new to Python so please go easy on me. I've been playing around with a personal project in terms of making a script that takes captured thermal temperature points (each pixel is a temperature value in a sheet), conditionally formats it in a gradient, and finds the top 10 values. I understand I can easily do this with excel, but I just want to try to do this with Python as a project for fun.

I currently have two methods working, one that gets the CSV as a data frame, and one that creates a new excel sheet applies the gradient to it and exports it as an xlsx. However, I don't know where to get started with highlighting the top 10 values, does Pandas have a library function for this?

I have thought about trying the sort function, however, that would rearrange the data and sort it in descending order, which would not work since I want to keep the cells in the locations where they are as they are pixels in an image.

Another idea that I had was starting at cell A1 and calling it rank 1 and comparing it to all the cells around it and have a bracket in terms of comparing values that way. However, I do not know where to get started with that idea.

Does anyone have any ideas on how to solve this? Thanks!

https://stackoverflow.com/questions/67014527/top-bottom-rule-conditional-formatting-in-python-like-excel April 09, 2021 at 11:05AM

没有评论:

发表评论