Efficient way to loop through spark dataframe and determine counts of column values as types : <p>I have a spark dataframe, I would like to loop through each column in the dataframe and determine the count of datatypes(int, string, boolean, datetype) for each column. NOT the column type overall, but the counts of each value as it's own type. So for example</p>

<pre><code>col_1|col_2|col_3
 aaa
 bbb
 14
 16
 true
</code></pre>

<p>So the counts for col_1 would be, strings=2, int=2, boolean=1</p>

<p>Is there a way to do this in spark? If so, how? How do I need to convert to rdd and loop through each row?</p>
