Fill Pattern

Solved!
davidhernandez
Level 3
Fill Pattern

I would like my output excel file to have colors.  But I need help with my python code that will color the cells.  Something like: 

If "Strong", then color the cells Green

If "Satisfactory", then color the cells Yellow

Then I need to connect the If statement to the Pattern Fill code: 

Fill_Pattern = PatternFill(patterntype='solid', fgcolor='00B050')

ws[insert appropriate columns].fill = fill_pattern

 

0 Kudos
1 Solution
tgb417

I've not done this before.

However, this might be interesting.

https://www.youtube.com/watch?v=ZXjHAxHyi9k

In Dataiku DSS we can of course use Jupyter Notebooks.
The interesting part here is the use of the engine openpyxl when Saving to move Pandas Dataframe formating into the resulting MS Excel file.

https://openpyxl.readthedocs.io/en/stable/formatting.html

Let us know how you get on with this.

--Tom

View solution in original post

0 Kudos
5 Replies
tgb417

Sounds like an interesting challenge.  It will likely be strongly dependent on the Python library you are choosing to work with.  What Python library are you using/ importing that has those capabilities?

--Tom
0 Kudos
davidhernandez
Level 3
Author
  • Hi Tom, sorry for the late reply.  We are just using the excel library. Uploading an excel document into Dataiku, and then I need to create the Python code, so that the output file will color certain cells based on the values in those cells.  Ie: all "Strong" should be color coded green
0 Kudos
tgb417

I've not done this before.

However, this might be interesting.

https://www.youtube.com/watch?v=ZXjHAxHyi9k

In Dataiku DSS we can of course use Jupyter Notebooks.
The interesting part here is the use of the engine openpyxl when Saving to move Pandas Dataframe formating into the resulting MS Excel file.

https://openpyxl.readthedocs.io/en/stable/formatting.html

Let us know how you get on with this.

--Tom
0 Kudos
Diwei
Level 2
U can try this.
 

p1.JPGp2.JPG

davidhernandez
Level 3
Author

Thank you will do!