code: def filter(self, f):
          
          def func(iterator):
              return filter(f, iterator)
          return self.mapPartitions(func, True)
docs: Return a new DStream containing only the elements that satisfy predicate.