code: def mapPartitions(self, f, preservesPartitioning=False):
          
          return (
              self
              .mapPartitionsWithIndex(lambda i, p: f(p), preservesPartitioning)
              .transform(lambda rdd:
                         rdd.setName('{}:{}'.format(rdd.prev.name(), f)))
          )
docs: Map partitions.
  
          :param f: mapping function
          :rtype: DStream