title: How to apply a list comprehension in Panda Dataframe?
body: <p>From a <code>list</code> of values, I try to identify any sequential pair of values whose sum exceeds 10</p>
  
  <pre><code>a = [1,9,3,4,5]
  </code></pre>
  
  <p>...so I wrote a <code>for</code> loop...</p>
  
  <pre><code>values = []
  for i in range(len(a)-2):
      if sum(a[i:i+2]) &gt;10:
          values += [a[i:i+2]]
  </code></pre>
  
  <p>...which I rewritten as a list comprehension...</p>
  
  <pre><code>values = [a[i:i+2] for i in range(len(a)-2) if sum(a[i:i+2]) &gt;10]
  </code></pre>
  
  <p>Both produce same output: </p>
  
  <pre><code>values = [[1,9], [9,3]]
  </code></pre>
  
  <p>My question is how best may I apply the above list comprehension in a DataFrame.</p>
  
  <p>Here is the sample 5 rows DataFrame</p>
  
  <pre><code>import pandas as pd
  df = pd.DataFrame({'A': [1,1,1,1,0], 
                     'B': [9,8,3,2,2],
                     'C': [3,3,3,10,3],
                     'E': [4,4,4,4,4],
                     'F': [5,5,5,5,5]})
  df['X'] = df.values.tolist()
  </code></pre>
  
  <p>where: 
  - a is within a <code>df['X']</code> which is a list of values Columns A - F</p>
  
  <pre><code>df['X'] = [[1,9,3,4,5],[1,8,3,4,5],[1,3,3,4,5],[1,2,10,4,5],[0,2,3,4,5]]
  </code></pre>
  
  <ul>
  <li>and, result of the list comprehension is to be store in new column <code>df['X1]</code> </li>
  </ul>
  
  <p>Desired output is:</p>
  
  <pre><code>df['X1'] = [[[1,9], [9,3]],[[8,3]],[[NaN]],[[2,10],[10,4]],[[NaN]]]
  </code></pre>
  
  <p>Thank you.</p>