Skip to content

Instantly share code, notes, and snippets.

@JonasHeylen
Last active May 10, 2016 14:00
Show Gist options
  • Save JonasHeylen/feea61c798fdb955f16b5ba785974e1a to your computer and use it in GitHub Desktop.
Save JonasHeylen/feea61c798fdb955f16b5ba785974e1a to your computer and use it in GitHub Desktop.
def diff(df1, df2, key):
def highlight_diff(col):
return ['background-color: yellow' if len(col.unique()) > 1 else '' for v in col]
s1 = df1.loc[key]
s2 = df2.loc[key]
return pd.DataFrame([s1, s2], index=['1', '2']).transpose().style.apply(highlight_diff, axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment