title: Pandas pivot time series data column into column of lists?
body: <p>I am working with some time series data that is set up in the following way:</p>
  <p><a href="https://i.stack.imgur.com/Q150Gm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q150Gm.png" alt="enter image description here" /></a></p>
  <p>The <code>indx</code> column starts at 1 and goes to around 434-460 (some series are longer than others) and then starts back at 1 again. What I would like to do is to transpose this so my dataframe looks like this where each row contains a couple lists for the time series:</p>
  <pre><code>         Time                                   MAG                      TAU               
  [time1,  time2,  ...,  timen]        [MAG1,  MAG2,  ..., MAGn]   (this is the value stored every time
            ...                                   ...               indx=1)
            ...                                   ...                       ...
  </code></pre>
  <p><strong>Edit</strong></p>
  <p>I have now tried to use <code>pd.pivot()</code> rather than <code>melt()</code> and this as as close as I've gotten. Using:</p>
  <pre><code>pd.pivot_table(df, index=['indx'], values=['MAG', 'time'], aggfunc=lambda x:list(x))
  </code></pre>
  <p>However, this just makes a really long list grouped by <code>indx</code>:</p>
  <p><a href="https://i.stack.imgur.com/Rcsyj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rcsyj.png" alt="enter image description here" /></a></p>