df.set_index('D', append=True).rename_axis(['col'], 1).rename_axis([None,
    'val2']).stack().to_frame('val').reset_index(['col', 'val2'])[['col',
    'val', 'val2']]
Pandas dataframe rearrangement stack to two value columns (for factorplots)