title: Python Pandas to_dict function
body: <p>I’m trying to create a dictionary, but can’t get it to work the way I intend.  I feel like I’m so close.  I a df of yelp data:</p>
  
  <pre><code>import pandas as pd
  file_rev = 'blah.csv'
  
  reviews=pd.read_csv(file_rev, sep=',',header=0, nrows=10000)
  
  cols = ['user_id', 'business_id', 'stars']
  cat_rev = reviews[cols]
  
  print cat_rev
  </code></pre>
  
  <p>df:</p>
  
  <pre><code>                   user_id             business_id  stars
  0   Xqd0DzHaiyRqVH3WRG7hzg  vcNAWiLM4dR7D2nwwJ7nCA      5
  1   H1kH6QZV7Le4zqTRNxoZow  vcNAWiLM4dR7D2nwwJ7nCA      2
  2   zvJCcrpm2yOZrxKffwGQLA  vcNAWiLM4dR7D2nwwJ7nCA      4
  3   KBLW4wJA_fwoWmMhiHRVOA  vcNAWiLM4dR7D2nwwJ7nCA      4
  4   zvJCcrpm2yOZrxKffwGQLA  vcNAWiLM4dR7D2nwwJ7nCA      4
  5   Qrs3EICADUKNFoUq2iHStA  vcNAWiLM4dR7D2nwwJ7nCA      1
  6   jE5xVugujSaskAoh2DRx3Q  vcNAWiLM4dR7D2nwwJ7nCA      5
  7   QnhQ8G51XbUpVEyWY2Km-A  vcNAWiLM4dR7D2nwwJ7nCA      5
  8   tAB7GJpUuaKF4W-3P0d95A  vcNAWiLM4dR7D2nwwJ7nCA      1
  9   GP-h9colXgkT79BW7aDJeg  vcNAWiLM4dR7D2nwwJ7nCA      5
  10  uK8tzraOp4M5u3uYrqIBXg  UsFtqoBl7naz8AVUBZMjQQ      5
  </code></pre>
  
  <p>I want to be able to create this as a dictionary that looks like:</p>
  
  <pre><code>abc = {user1 : {business1:star_rating, business2:star_rating…, 
                  businessN:star_rating}, 
         user2: {} … }
  </code></pre>
  
  <p>Then to access I would just: 
  <code>abc[user1]</code> would give me all the places and stars that user1 reviewed.<br>
  <code>abc[user1][place1]</code> would give just corresponding star rating.  </p>
  
  <p>I’ve tried the <code>to_dict</code> panda function.  I tried to <code>groupby</code> first, then <code>dict(list(groupby()))</code>, and nothing seems to convert it to how I want.</p>
  
  <p>Also nope, but almost:</p>
  
  <pre><code>ddd = cat_rev.set_index('user_id').to_dict(outtype='list')
  </code></pre>