unused_cols = ['ANO', 'MNO']
cols = df.columns.difference(unused_cols)
fnc = lambda x: x[1:]
pref1, pref2 = 'D', 'U'
groups = [list(g) for n, g in groupby(sorted(cols, key=fnc), key=fnc)]
fill_missing = [(i if len(i) == 2 else i + [pref1 + i[0][1:] if i[0][0] ==
    pref2 else pref2 + i[0][1:]]) for i in groups]
df = df.reindex(columns=unused_cols + list(chain(*fill_missing)))
pandas column values to row values