vgrabovets
3/20/2017 - 4:17 PM

sort dataframe columns

sort dataframe columns

def reg_search(x):
    res = re.findall(r'\d+(?: \d+)?', x)
    if not res:
        return -1
    else:
        res = re.sub(' ', '', res[0])
        return int(res)
        
wf_total = wf_total.reindex_axis(sorted(wf_total.columns, key=lambda x: reg_search(x)), axis=1)