a guest Nov 17th, 2017 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- data = pd.DataFrame(np.random.randn(5, 3), columns=list('ABC'))
- #print (data)
- def highlight_cols(x):
- #copy df to new - original data are not changed
- df = x.copy()
- #select all values to default value - red color
- df.loc[:,:] = 'background-color: red'
- #overwrite values grey color
- df[['B','C']] = 'background-color: grey'
- #return color df
- return df
- data.style.apply(highlight_cols, axis=None)
RAW Paste Data