title: Selecting several columns from spark dataframe with a list of columns as a start
body: <p>Assuming that I have a list of spark columns and a spark dataframe df, what is the appropriate snippet of code in order to select a subdataframe containing only the columns in the list?</p>
  
  <p>Something similar to maybe:</p>
  
  <pre><code>var needed_column: List[Column]=List[Column](new Column("a"),new Column("b"))
  
  df(needed_columns)
  </code></pre>
  
  <p>I wanted to get the columns names then select them using the following line of code. </p>
  
  <p>Unfortunately, the column name seems to be in write mode only.</p>
  
  <pre><code>df.select(needed_columns.head.as(String),needed_columns.tail: _*)
  </code></pre>