title: How to perform calculations on dictionaries like data frames
body: <p>I'm using binance websocket api to get bids and asks from an orderbook as a json and would like to perform some calculations. The dictionary looks like this:<code>{'bids': [['20768.16000000', '0.07273000'], [....]] 'asks': [['20770.77000000', '0.00096000'], [...]]}</code>
  Given a dictionary of tuples, is there a way to multiply the values inside the tuples and add them all up?</p>
  <p>For example, Currently I'm using pandas but I'd guess it's more efficient without the need of an extra data frame:</p>
  <pre><code>    bids = pd.DataFrame(response['bids_size'])
      asks = pd.DataFrame(response['asks_size'])
      df = pd.merge(bids, asks, left_index=True, right_index=True)
      df = df.apply(pd.to_numeric)
  
          0_x      1_x       0_y      1_y
     0  20768.16  0.07273  20770.77  0.00096  
     1  20767.49  0.01352  20771.15  0.03400   
     2  20767.38  0.04119  20771.19  0.05400   
     3  20767.28  0.00055  20771.20  0.12411   
     4  20766.83  0.04000  20771.22  0.00962
  
  
      
  
      df['bids'] = df['0_x'] * df['1_x']
      df['asks'] = df['0_y'] * df['1_y']
  </code></pre>
  <p>gives:</p>
  <pre><code>    0_x      1_x       0_y      1_y       bids_size     asks_size
  0  20768.16  0.07273  20770.77  0.00096  1510.468277    19.939939
  1  20767.49  0.01352  20771.15  0.03400   280.776465   706.219100
  2  20767.38  0.04119  20771.19  0.05400   855.408382  1121.644260
  3  20767.28  0.00055  20771.20  0.12411    11.422004  2577.913632
  4  20766.83  0.04000  20771.22  0.00962   830.673200   199.819136     
  </code></pre>
  <p>does anyone know if this can be done directly from the dictionary? thanks</p>
  <p>Edit:
  a dictionary response would look as such:</p>
  <pre><code>{'bids': [['23767.25000000', '0.00100000'], ['23766.82000000', 
  '0.02102000'], ['23766.81000000', 
  '0.01081000'], ['23766.79000000', '0.01758000'], ['23766.75000000', 
  '0.00051000'], ['23766.10000000', '0.00168000'], ['23766.01000000', 
  '0.00400000'], ['23765.95000000', '0.00092000'], ['23765.40000000', 
  '0.13471000'], ['23765.06000000', '0.04420000']], 'asks': 
  [['23768.53000000', '0.00195000'], ['23768.57000000', '0.10468000'], 
  ['23768.68000000', '0.13800000'], ['23768.93000000', '0.00166000'], 
  ['23769.02000000', '0.01709000'], ['23769.38000000', '0.01799000'], 
  ['23770.67000000', '0.00515000'], ['23771.58000000', '0.00696000'], 
  ['23771.75000000', '0.05799000'], ['23771.76000000', '0.13800000']]}
  </code></pre>