title: Aggregate Boolean values in Pyspark Dataframe
body: <p>I'm trying to transpose some columns of my table to rows and aggregate their values. I would like to have three columns, representing Boolean values (1, 0, Null). The cells should then represent the number of occurrence of those values in the original data frame columns. I'm using Python and Spark 2.4.0.</p>
  
  <p>Here is my initial table:</p>
  
  <pre><code>+-----+-----+-----+-------+
  |col_1|col_2|col_3|col_...|
  +-----+-------------------+
  |  0  |  1  |  0  |  ...  |
  |  1  |  0  |  0  |  ...  |
  | NaN |  0  |  0  |  ...  |
  |  ...|  ...|  ...|  ...  |
  </code></pre>
  
  <p>I would like to have something like this: </p>
  
  <pre><code>+------+------+------+------+
  |column| ones |zeroes| nans |
  +------+--------------------+
  | col_1|   1  |   1  |   1  |
  | col_2|   1  |   2  |   0  |
  | col_3|   0  |   3  |   0  |
  |  ... |  ... |  ... |  ... |
  </code></pre>
  
  <p>A solution where the columns of the input and the desired output are the same and with the aggregated values as rows is also fine for me. </p>