2

I want to use the color coding from a pandas style object and apply the exact same coloring to the corresponding cells in another dataframe with the same size. The data is different in the two dataframes which means i can not use the same styling function.

I have tried using style.render() from the style object with the desired color and then apply it to the new dataframe. This did not work for me though.

EDIT: I have posted a picture below of what i have tried to do. In the picture i use the .render() method to get the HTML of the dataframe with the color coding and apply it to a new dataframe, but without success.

styling

4
  • Please show us what you tried, paste your code and where you are facing problem? Commented Aug 29, 2019 at 9:01
  • I have added a picture with an example of what i am trying to accomplish Commented Aug 29, 2019 at 10:11
  • did you try with , style1=df1.style.apply(highlight_max) , style2 = df2.style , style2.use(style1.export()) then style2? Commented Aug 29, 2019 at 10:53
  • Yes, i have tried this. The problem with this is that it simply uses the same styling function (highlight_max) on df2. I want to use the same coloring schema that that is generated when using the styling function on df1 and then apply this coloring to df2 Commented Aug 29, 2019 at 11:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.