Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 17th, 2017 110 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. data =  pd.DataFrame(np.random.randn(5, 3), columns=list('ABC'))
  2. #print (data)
  3.  
  4. def highlight_cols(x):
  5.     #copy df to new - original data are not changed
  6.     df = x.copy()
  7.     #select all values to default value - red color
  8.     df.loc[:,:] = 'background-color: red'
  9.     #overwrite values grey color
  10.     df[['B','C']] = 'background-color: grey'
  11.     #return color df
  12.     return df    
  13.  
  14. data.style.apply(highlight_cols, axis=None)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top