code: def countByValue(self):
          
          return self.transform(
              lambda rdd: self._context._context.parallelize(
                  rdd.countByValue().items()))
docs: Apply countByValue to every RDD.abs
  
          :rtype: DStream
  
          .. warning::
              Implemented as a local operation.
  
  
          Example:
  
          >>> import pysparkling
          >>> sc = pysparkling.Context()
          >>> ssc = pysparkling.streaming.StreamingContext(sc, 0.1)
          >>> (
          ...     ssc
          ...     .queueStream([[1, 1, 5, 5, 5, 2]])
          ...     .countByValue()
          ...     .foreachRDD(lambda rdd: print(sorted(rdd.collect())))
          ... )
          >>> ssc.start()
          >>> ssc.awaitTermination(0.15)
          [(1, 2), (2, 1), (5, 3)]