code: def count(self):
          
          return (
              self
              .mapPartitions(lambda p: [sum(1 for _ in p)])
              .reduce(operator.add)
          )
docs: Count elements per RDD.
  
          Creates a new RDD stream where each RDD has a single entry that
          is the count of the elements.
  
          :rtype: DStream