title: How to transform Spark Dataframe columns to a single column of a string array
body: <p>I want to know how can I "merge" multiple dataframe columns into one as a string array?</p>
  
  <p>For example, I have this dataframe:</p>
  
  <pre><code>val df = sqlContext.createDataFrame(Seq((1, "Jack", "125", "Text"), (2,"Mary", "152", "Text2"))).toDF("Id", "Name", "Number", "Comment")
  </code></pre>
  
  <p>Which looks like this:</p>
  
  <pre><code>scala&gt; df.show
  +---+----+------+-------+
  | Id|Name|Number|Comment|
  +---+----+------+-------+
  |  1|Jack|   125|   Text|
  |  2|Mary|   152|  Text2|
  +---+----+------+-------+
  
  scala&gt; df.printSchema
  root
   |-- Id: integer (nullable = false)
   |-- Name: string (nullable = true)
   |-- Number: string (nullable = true)
   |-- Comment: string (nullable = true)
  </code></pre>
  
  <p>How can I transform it so it would look like this:</p>
  
  <pre><code>scala&gt; df.show
  +---+-----------------+
  | Id|             List|
  +---+-----------------+
  |  1|  [Jack,125,Text]|
  |  2| [Mary,152,Text2]|
  +---+-----------------+
  
  scala&gt; df.printSchema
  root
   |-- Id: integer (nullable = false)
   |-- List: Array (nullable = true)
   |    |-- element: string (containsNull = true)
  </code></pre>