Python Pandas Melt Groups of Initial Columns Into Multiple Target Columns
<p>I have a need to melt groups of initial columns into multiple target columns in a dataset that is not normalized well.  Here is an example (from this question <a href="https://stackoverflow.com/questions/32105368/pandas-dataframe-reshaping-stacking-of-multiple-value-variables-into-seperate-co">pandas dataframe reshaping/stacking of multiple value variables into seperate columns</a>):</p>

<pre><code>         des1 des2 des3 interval1 interval2 interval3
value   
aaa       a    b    c     ##1         ##2       ##3
bbb       d    e    f     ##4         ##5       ##6
ccc       g    h    i     ##7         ##8       ##9
</code></pre>

<p>I am trying to melt this into something like this orientation:</p>

<pre><code>         des      interval
value   
aaa       a         ##1
aaa       b         ##2
aaa       c         ##3
bbb       d         ##4
bbb       e         ##5
bbb       f         ##6
ccc       g         ##7
ccc       h         ##8
ccc       i         ##9
</code></pre>

<p>I was hoping to use melt instead of stack to avoid manually subsetting a lot of data.  Here is what I have started out with thus far:</p>

<pre><code>import pandas as pd
import numpy as np
import fnmatch

column_list = list(df_initial.columns.values)

question_sources = [c for c in fnmatch.filter(column_list, "measure*question*source")]     
question_ranks = [c for c in fnmatch.filter(column_list, "measure*rank")]
question_targets = [c for c in fnmatch.filter(column_list, "measure*targeted")]
question_statuses = [c for c in fnmatch.filter(column_list, "measure*status")]

place = [c for c in fnmatch.filter(column_list, "place")]
measure_statuses = [c for c in fnmatch.filter(column_list, "measureInfo_status")]

starter_list = place + measure_statuses

df_gpro_melt_1 = (pd.melt(df_initial, id_vars=starter_list,      
                    value_vars=question_sources, var_name="question_sources", 
                    value_name="question_sources_values"))      
</code></pre>

<p>Is it possible to melt groups of initial columns into multiple target columns?  Any advice is much appreciated. </p>