title: How to colour rows in a dataframe using style.applymap()?
body: <p>I want to colour both the 'Grand Total' row and the 'Total' column in a DataFrame object <code>df</code>, for which I tried the following:</p>
  <pre><code>import pandas as pd
  
  # Function to set background highlight colour.
  def bg_colour (val):
      colour = '#ffff00'
      return 'background-color: %s' % colour
  
  df = pd.DataFrame({'Category': ['A','B','C','D','Grand Total'], 'Total': [1,2,3,4,10]})
  t1 = df.style.applymap(bg_colour, subset = ['Total'])
  dfT = df.T
  dfT = dfT.style.applymap(bg_colour, subset = [4])
  t1T = t1.T
  </code></pre>
  <p>However, when the compiler reaches the last line of the code, the following error arises:</p>
  <pre><code>---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-48-c0c380b9c518&gt; in &lt;module&gt;
        12 dfT = dfT.style.applymap(bg_colour, subset = [4])
        13 display(dfT)
   ---&gt; 14 t1T = t1.T
   
  AttributeError: 'Styler' object has no attribute 'T'
  </code></pre>
  <p>From what I understand, <code>style.applymap()</code> implicitly converts DataFrame into a Styler-type object, which cannot be further manipulated as a DataFrame.</p>
  <p><strong>Question 1</strong>: How can both rows and columns of a DataFrame object be coloured?</p>
  <p><strong>Question 2</strong>: How can a Styler-type object be converted into a DataFrame-type one?</p>