title: Summing values across each row as boolean (PySpark)
body: <p>I currently have a PySpark dataframe that has many columns populated by integer counts. Many of these columns have counts of zero. <strong>I would like to find a way to sum how many columns have counts greater than zero</strong>. </p>
  
  <p>In other words, I would like an approach that sums values across a row, where all the columns for a given row are effectively boolean (although the datatype conversion may not be necessary). Several columns in my table are datetime or string, so ideally I would have an approach that first selects the numeric columns.</p>
  
  <p><strong>Current Dataframe example and Desired Output</strong></p>
  
  <pre><code>+---+---------- +----------+------------            
  |USER|   DATE   |COUNT_COL1| COUNT_COL2|...     DESIRED COLUMN
  +---+---------- +----------+------------ 
  | b | 7/1/2019 |  12      |     1     |              2        (2 columns are non-zero)
  | a | 6/9/2019 |  0       |     5     |              1
  | c | 1/1/2019 |  0       |     0     |              0
  
  </code></pre>
  
  <p><strong>Pandas:</strong> As an example, in pandas this can be accomplished by selecting the numeric columns,converting to bool and summing with the axis=1. I am looking for a PySpark equivalent.</p>
  
  <pre><code>test_cols=list(pandas_df.select_dtypes(include=[np.number]).columns.values)
  pandas_df[test_cols].astype(bool).sum(axis=1)
  </code></pre>