for i, l in enumerate(table):
    l.insert(0, y_axis[i])
x_axis.insert(0, ' ')
table.insert(0, x_axis)
col_paddings = [get_max_col_w(table, i) for i in range(len(table[0]))]
for i, row in enumerate(table):
    row_tab = [str(row[0]).ljust(col_paddings[0])]
row_tab += [format_field(row[j]).rjust(col_paddings[j]) for j in range(1,
    len(row))]
print(' '.join(row_tab))
x_axis = ['x{}'.format(c) for c in names]
y_axis = ['y{}'.format(c) for c in names]
pptable(x_axis, y_axis, a.tolist())
How to generate a clean x and y axis for a numpy matrix?