This is a variation of the question "Pandas DataFrames in Jupyter: columns of equal width and centered".
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?
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])