I am a newbie and know below commands. They give count of values by key and list of values by key.

```
dayToHostPairTuple.countByKey()
dayToHostPairTuple.groupByKey()

```

is there any simple alternative to countByKey that will count only distinct values by key?

#########################################==

Below code works for me. It is based upon answers that i received.

```
dayToHostPairTuple = access_logs.map(lambda log: (log.date_time.day, log.host))
dayToHostPairTuple=dayToHostPairTuple.sortByKey()
print dayToHostPairTuple.distinct().countByKey()

```