title: How to convert an RDD into a 2d array in Scala?
body: <p>I am using Apache Spark for a project. I have a <code>DataFrame</code>. I have been able to convert it into an <code>RDD</code>. I need to convert it into a <em>2d array</em>. Below is the code that I have written. What should I do next?</p>
  
  <pre><code>val x: List[List[String]] = df.select(columnNames(0), (columnNames.drop(1): _*)).rdd.collect()
  </code></pre>
  
  <p>Here <em>df</em> is <code>DataFrame</code>.</p>