title: Iterating through a Spark RDD
body: <p>Starting with a Spark DataFrame to create a vector matrix for further analytics processing.</p>
  
  <pre><code>feature_matrix_vectors = feature_matrix1.map(lambda x: Vectors.dense(x)).cache()
  feature_matrix_vectors.first()
  </code></pre>
  
  <p>The output is an array of vectors. Some of those vector have an null in them</p>
  
  <pre><code>&gt;&gt;&gt; DenseVector([1.0, 31.0, 5.0, 1935.0, 24.0])
  ...
  &gt;&gt;&gt; DenseVector([1.0, 1231.0, 15.0, 2008.0, null])
  </code></pre>
  
  <p>From this i want to iterate through the vector matrix and create an LabeledPoint array with 0 (zero) if the vector contains a null, otherwise with a 1.</p>
  
  <pre><code>def f(row):
      if row.contain(None):
         LabeledPoint(1.0,row)
      else:
         LabeledPoint(0.0,row)
  </code></pre>
  
  <p>I have tried to iterate through the vector matrix using</p>
  
  <pre><code>feature_matrix_labeledPoint = (f(row) for row in feature_matrix_vectors) #   create a generator of row sums
  next(feature_matrix_labeledPoint) # Run the iteration protocol
  </code></pre>
  
  <p>but this doesn't work. </p>
  
  <pre><code>TypeError: 'PipelinedRDD' object is not iterable
  </code></pre>
  
  <p>Any help would be great</p>