def clean_label(label_list, margins='False'):
    """ This function takes the column index list from a crosstab (or pivot table?) in pandas and removes the 
    part of the label before and including the "_".  This allows the user to order the columns manually by creating
    an alphabetical index followed by "_" and then the label that they would like to use.  For example, a label such as
    ['a_Positive', 'b_Negative'] will be converted to ['Positive', 'Negative'].  Another example would be to order dates
    in a table from ['12 10_Oct 12', '12 11_Nov 12'] to ['Oct 12', 'Nov 12']
    margins = False if the crosstab was created without margins and therefore does not have an "All" at the end of the list
    margins = True if the crosstab was created with margins and therefore has an "All" at the end of the list
    """
corrected_list = list()
if margins:
    convert_list = label_list[:-1]
else:
    convert_list = label_list
for l in convert_list:
    x, y = l.split('_')
corrected_list.append(y)
if margins:
    corrected_list.append('Total')
return corrected_list
table_1.columns = clean_label(table_1.columns, margins=True)
table_1.columns.name = 'Month of Collection'
table_1.index.name = 'Region'
Кросс-таблица Pandas: изменить порядок столбцов, названных как отформатированные даты (ммм, гг)