title: Add to cell in a Pandas dataframe from a dictionary in another cell
body: <p>I have a pandas dataframe like this:</p>
  
  <pre class="lang-py prettyprint-override"><code>datadict = {"StationID":[102,103,11],"Bikes_Available":[10,3,2], "Suggested_Movements":[{11:3,103:5}, {11:3}, {103:1}]}
  df = pd.DataFrame.from_dict(datadict)
  
  StationID Bikes_Available   Suggested_Movements
  102       10                {11: 3, 103: 5}
  103        3                {11: 3}
  11         2                {103: 1}
  </code></pre>
  
  <p>The last column is a dictionary. The keys represent a StationID that bikes should be moved to, and the values are the number of bikes that should be moved. I want to create a new column that shows how many bikes should be added to each StationID. I need to look up each dictionary of Suggested_Movements and sum all the bikes that are being moved to each station.
  The output would look like this:</p>
  
  <pre><code>StationID Bikes_Available   Suggested_Movements To_Add
  102       10                {11: 3, 103: 5}      0
  103        3                {11: 2}              6
  11         2                {103: 1}             5 
  </code></pre>
  
  <p>Station 102 gets 0 bikes added. Station 103 gets 6 added, 5 from station 102 and 1 from station 11. Station 11 gets 5 added, 3 from 102 and 2 from 103.
  I've tried using apply with lambdas, but I can't get the logic right.<br>
  One issue is not being able to use the ID column as dictionary keys for the 'Suggested_Movements' column because they are hashable. To get around that, I tried converting them first to strings and then back to integers so they would be recognized as dictionary keys as follows: </p>
  
  <pre><code>df['to add'] = df['Suggested_Movements'].apply(lambda x: x.get(int(df['StationID'].to_string())))
  </code></pre>
  
  <p>This gave me the following error:</p>
  
  <pre><code>ValueError: invalid literal for int() with base 10: '0      102\n1      103\n2       11\n3       12\n4      133\n5      134\n6      145\n7      156\n8      157\n9      161\n10     172\n11       2\n12     217\n13      24\n14     259\n15     270\n16
  </code></pre>
  
  <p>which shows that there are additional characters added to the station indices. I suppose I could add <code>.split('\\')[0]</code> to get only the number I need, but something is going wrong with that too, and this seems to convoluted to be the proper way to do this.<br>
  I also tried this:<br>
   <code>df['To_Add'] = df[StationID].map(df["Suggested_Movements"]).fillna(df['To_add'])</code></p>
  
  <p>based on another question, which just gave me a copy of the whole dictionary in the last column. </p>