title: Number of unique elements in all columns of a pyspark dataframe
body: <p>How it is possible to calculate the number of unique elements in each column of a pyspark dataframe:</p>
  
  <pre><code>import pandas as pd
  from pyspark.sql import SparkSession
  
  spark = SparkSession.builder.getOrCreate()
  df = pd.DataFrame([[1, 100], [1, 200], [2, 300], [3, 100], [4, 100], [4, 300]], columns=['col1', 'col2'])
  df_spark = spark.createDataFrame(df)
  print(df_spark.show())
  # +----+----+
  # |col1|col2|
  # +----+----+
  # |   1| 100|
  # |   1| 200|
  # |   2| 300|
  # |   3| 100|
  # |   4| 100|
  # |   4| 300|
  # +----+----+
  
  # Some transformations on df_spark here
  
  # How to get a number of unique elements (just a number) in each columns?
  </code></pre>
  
  <p>I know only the following solution which is very slow, both of these lines are calculated in the same amount of time:</p>
  
  <pre><code>col1_num_unique = df_spark.select('col1').distinct().count()
  col2_num_unique = df_spark.select('col2').distinct().count()
  </code></pre>
  
  <p>There are about 10 millions rows in <code>df_spark</code>.</p>