code: def get_one_ping_per_client(pings):
      
      if isinstance(pings.first(), binary_type):
          pings = pings.map(lambda p: json.loads(p.decode('utf-8')))
  
      filtered = pings.filter(lambda p: "clientID" in p or "clientId" in p)
  
      if not filtered:
          raise ValueError("Missing clientID/clientId attribute.")
  
      if "clientID" in filtered.first():
          client_id = "clientID"  # v2
      else:
          client_id = "clientId"  # v4
  
      return filtered.map(lambda p: (p[client_id], p)) \
                     .reduceByKey(lambda p1, p2: p1) \
                     .map(lambda p: p[1])
docs: Returns a single ping for each client in the RDD.
  
      THIS METHOD IS NOT RECOMMENDED: The ping to be returned is essentially
      selected at random. It is also expensive as it requires data to be
      shuffled around. It should be run only after extracting a subset with
      get_pings_properties.