title: Pyspark dataframe: Count elements in array or list
body: <p>Let us assume dataframe <code>df</code> as:</p>
  
  <pre><code>df.show()
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>+------+----------------+
  |letter| list_of_numbers|
  +------+----------------+
  |     A|    [3, 1, 2, 3]|
  |     B|    [1, 2, 1, 1]|
  +------+----------------+
  </code></pre>
  
  <p>What I want to do is to <code>count</code> number of a specific element in column <code>list_of_numbers</code>. Something like this:</p>
  
  <pre><code>+------+----------------+----+
  |letter| list_of_numbers|ones|
  +------+----------------+----+
  |     A|    [3, 1, 2, 3]|   1|
  |     B|    [1, 2, 1, 1]|   3|
  +------+----------------+----+
  </code></pre>
  
  <p>I have so far tried creating <code>udf</code> and it perfectly works, but I'm wondering if I can do it without defining any <code>udf</code>.</p>