title: Value of specific key from a dictionary using lambda?
body: <p>I have a product array which looks like table below:<pre><sub>+---------------------------+--------------------------------+--------------------------------+
  |    name                   |  review                        | word_count                     |
  +---------------------------+--------------------------------+--------------------------------+
  |                           |                                | {'and': 5, 'wipes': 1,         |
  | Planetwise                |  These flannel wipes are OK,   | 'stink': 1, 'because' : 2, ... |
  | Flannel Wipes             |  but in my opinion ...         |                                |
  |                           |                                |                                |
  +---------------------------+--------------------------------+--------------------------------+
  |                           |                                | {'and': 3, 'love': 1,          |
  | Planetwise                |  it came early and was not     | 'it': 2, 'highly': 1, ...      |
  | Wipes Pouch               |  disappointed. i love ...      |                                |
  |                           |                                |                                |
  +---------------------------+--------------------------------+--------------------------------+
  |                           |                                | {'shop': 1, 'noble': 1,        |
  |                           |                                | 'is': 1, 'it': 1, 'as': ...    |
  | A Tale of Baby's Days     |  Lovely book, it's bound       |                                |
  |  with Peter Rabbit ...    |  tightly so you may no ...     |                                |
  |                           |                                |                                |
  +---------------------------+--------------------------------+--------------------------------+
  </sub></pre></p>
  
  <p>Basically the <code>word_count</code> column contains a <code>dictionary(key : value)</code> of word occurrence of <code>review</code> columns sentences.</p>
  
  <p>Now I want to build a new column name <code>and</code> which should contain value of <code>and</code> in <code>word_count</code> dictionary, if <code>and</code> exists as a key in the <code>word_count</code> column, then the value, if it doesn't exist as a key, then <code>0</code>.</p>
  
  <p>For first 3 rows the new <code>and</code> column looks something like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>+------------+
  |    and     |
  +------------+
  |            |
  | 5          |
  |            |
  |            |
  +------------+
  |            |
  | 3          |
  |            |
  |            |
  +------------+
  |            |
  | 0          |
  |            |
  |            |
  +------------+
  </code></pre>
  
  <p>I wrote this code and it's working correctly:</p>
  
  <pre><code>def wordcount(x):
      if 'and' in x:
          return x['and']
      else:
          return 0
  
  products['and'] = products['word_count'].apply(wordcount);
  </code></pre>
  
  <p><strong>My question:</strong> Is there any way I can do this using <code>lambda</code>?</p>
  
  <p>What I've done so far is:</p>
  
  <pre><code>products['and'] = products['word_count'].apply(lambda x : 'and' in x.keys());
  </code></pre>
  
  <p>This returns only <code>0</code> or <code>1</code> in columns. What can I add to the line above so that <code>products['and']</code> contains the value of <code>and</code> the key when it exists as a key in <code>products['word_count']</code>?</p>
  
  <p>I'm using ipython notebook and graphlab.</p>