title: pyspark: counting number of occurrences of each distinct values
body: <p>I think the question is related to: <a href="https://stackoverflow.com/questions/40888946/spark-dataframe-count-distinct-values-of-every-column">Spark DataFrame: count distinct values of every column</a></p>
  
  <p>So basically I have a spark dataframe, with column <code>A</code> has values of <code>1,1,2,2,1</code></p>
  
  <p>So I want to count how many times each distinct value (in this case, <code>1</code> and <code>2</code>) appears in the column <code>A</code>, and print something like</p>
  
  <pre><code>distinct_values | number_of_apperance
  1 | 3
  2 | 2
  </code></pre>