import pandas
import numpy as np
import matplotlib.pyplot as plt
df = pandas.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')
df=df[:15]
fig, ax = plt.subplots()
ax.axis('off')
ax.axis('tight')
tab=ax.table(cellText=df.values, colLabels=df.columns, loc='center',cellLoc='center')
tab.auto_set_font_size(False)
tab.auto_set_column_width(col=list(range(len(df.columns))))
for k, cell in tab._cells.items():
cell.set_linewidth(0)
if k[0] == 0:
cell.set_text_props(weight='bold', color='w')
cell.set_facecolor('#222B35')
elif k[0]%2==0:
cell.set_facecolor('#D9D9D9')
plt.tight_layout()
But I wanted, for example, to merge and center the columns headers for sepal_width
and petal_length,
which would give me something like: