title: Remove elements from Spark RDD
body: <p>I am building an RDD from a text file. Some of the lines do not conform to the format I am expecting, in which case I use the marker -1.</p>
  
  <pre><code>def myParser(line):
      try:
          # do something
      except:
          return (-1, -1), -1
  
  lines = sc.textFile('path_to_file')
  pairs = lines.map(myParser)
  </code></pre>
  
  <p>is it possible to remove the lines with the <code>-1</code> marker? If not, what would be the workaround for it?</p>