title: Python - Using pandas to format excel cell
body: <p>I have a pandas dataframe, which is something like shown below.</p>
  
  <p><a href="https://i.stack.imgur.com/xDSrJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xDSrJ.png" alt="dataframee"></a></p>
  
  <p>I would like to format the column "Pass/Fail" as <code>if Fail --&gt; red background, else green background</code>, like: </p>
  
  <p><a href="https://i.stack.imgur.com/VVvxn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VVvxn.png" alt="format"></a></p>
  
  <p>I have tried to use Pandas to do the formatting, but it fails to add color to the excel. Following is the code: </p>
  
  <pre><code>writer = pandas.ExcelWriter(destination,engine = 'xlsxwriter')
  color = Answer.style.applymap(lambda x: 'color: red' if x == "Fail" else 'color: green',subset= pandas.IndexSlice[:,['Pass/Fail']])
  color.to_excel(writer,'sheet1')
  </code></pre>
  
  <p>I tried StyleFrame which failed to install. Seems that StyleFrame does not comply with my python version 3.6. </p>
  
  <p>How can I format the excel as I want? </p>