I have two dataframes containing dates:
df1:
Name A B C
D1 2018-04-26 2018-04-24 2018-04-24
D2 2018-04-25 2018-04-23 2018-04-23
D3 2018-04-25 2018-04-26 2018-04-26
df2:
Name A B C
D1 2018-04-24 2018-04-23 2018-04-24
D2 2018-04-25 2018-04-23 2018-04-21
D3 2018-04-22 2018-04-24 2018-04-23
Let's say i would like to style df1 such that if a value does not equal the corresponding value in df2, it highlights the cell red.
I know i need to create a function and use
df1.style.applymap()
but i'm having trouble putting the function together. Something like;
def diffindicator(val):
color = 'white'
if val != df2:
color = 'red'
return 'background-color: %s' % color