Selecting only numeric/string columns names from a Spark DF in pyspark : <p>I have a SparkDataFrame in pyspark (2.1.0) and I am looking to get the names of numeric columns only or string columns only.</p>

<p>For example, this is the Schema of my DF:</p>

<pre><code>root
 |-- Gender: string (nullable = true)
 |-- SeniorCitizen: string (nullable = true)
 |-- MonthlyCharges: double (nullable = true)
 |-- TotalCharges: double (nullable = true)
 |-- Churn: string (nullable = true)
</code></pre>

<p>This is what I need:</p>

<pre><code>num_cols = [MonthlyCharges, TotalCharges]
str_cols = [Gender, SeniorCitizen, Churn]
</code></pre>

<p>How can I make it? Thank you!</p>
