title: How to create a dictionary of lists from two columns in a dataframe
body: <p>I have a dataframe like this</p>
  
  <pre><code>df = pd.DataFrame(columns = ['A', 'B'])
  df.A = [1,1,1,2,2,2,2,4,4,5]
  df.B = [5,2,4,3,1,5,4,1,2,2]
  </code></pre>
  
  <p>What I'm currently using</p>
  
  <pre><code>d = {}
  for i in df.A:
      d[i] = []
      for v in df.A[df.A == i].index:
          d[i].append(df.B[v])
  </code></pre>
  
  <p>Resulting in </p>
  
  <pre><code>{1: [5, 2, 4], 2: [3, 1, 5, 4], 4: [1, 2], 5: [2]}
  </code></pre>
  
  <p>But it's slow. </p>
  
  <p>What is a pythonic way of doing this?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>d = {}
  for i in df.A.unique():
      d[i] = df[df.A == i].B.tolist()
  </code></pre>
  
  <p>Still seems like there must be a faster way</p>
  
  <p>Thanks for any help!</p>