code: def map(self, f, preservesPartitioning=False):
          
          return (
              self
              .mapPartitions(lambda p: (f(e) for e in p), preservesPartitioning)
              .transform(lambda rdd:
                         rdd.setName('{}:{}'.format(rdd.prev.name(), f)))
          )
docs: Apply function f
  
          :param f: mapping function
          :rtype: DStream
  
  
          Example:
  
          >>> import pysparkling
          >>> sc = pysparkling.Context()
          >>> ssc = pysparkling.streaming.StreamingContext(sc, 0.1)
          >>> (
          ...     ssc
          ...     .queueStream([[4], [2], [7]])
          ...     .map(lambda e: e + 1)
          ...     .foreachRDD(lambda rdd: print(rdd.collect()))
          ... )
          >>> ssc.start()
          >>> ssc.awaitTermination(0.35)
          [5]
          [3]
          [8]