title: Pandas DataFrames in Jupyter: formatting index and columns separately
body: <p>This is a variation of the question <a href="https://stackoverflow.com/questions/40990700/pandas-dataframes-in-jupyter-columns-of-equal-width-and-centered?answertab=votes#tab-top">"Pandas DataFrames in Jupyter: columns of equal width and centered"</a>. </p>
  
  <p>How can we display an indexed dataframe with all columns centered except the index, which should be aligned left? And also, how can we control the width and other attributes of the index? </p>
  
  <pre><code>import pandas as pd
  raw_data = {'Regiment': ['Nighthawks', 'Raptors'], 
      'Company': ['1st', '2nd'], 
      'preTestScore': [4, 24],
      'postTestScore': [25, 94]}
  df = pd.DataFrame(raw_data, columns = ['Regiment', 'Company', 'preTestScore', 'postTestScore']).set_index('Regiment')
  d = dict(selector="th",
      props=[('text-align', 'center')])
  
  df.style.set_properties(**{'width':'10em', 'text-align':'center'})\
          .set_table_styles([d])
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/yVGQ3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yVGQ3.jpg" alt="enter image description here"></a></p>