I have two 3X3 pandas DataFrames df1
A B C
0 8 3 9
1 1 7 7
2 3 3 8
and df2.
A B C
0 2 1 2
1 5 9 7
2 1 8 3
What I want to obtain is a tabulated Jupyter Notebook output whose elements are the same as df1 but their font color is red if the element value is greater than the corresponding value of df2.
Thus, the expected output is something like the following
A B C
0 8(r) 3(r) 9(r)
1 1 7 7
2 3(r) 3 8(r)
(r) means the font color of the cell is red, not real printout.
What I tried was applymap method like this
df1.style.applymap(lambda x: 'color : red' if x > df2 else '')
but could not figure out how to set labmda x and df2 on an equal footing.
Could anyone help?
