title: Spark Dataframe select based on column index
body: <p>How do I select all the columns of a dataframe that has certain indexes in Scala?</p>
  
  <p>For example if a dataframe has 100 columns and i want to extract only columns (10,12,13,14,15), how to do the same?</p>
  
  <p>Below selects all columns from dataframe <code>df</code> which has the column name mentioned in the Array colNames:</p>
  
  <pre><code>df = df.select(colNames.head,colNames.tail: _*)
  </code></pre>
  
  <p>If there is similar, colNos array which has</p>
  
  <pre><code>colNos = Array(10,20,25,45)
  </code></pre>
  
  <p>How do I transform the above <code>df.select</code> to fetch only those columns at the specific indexes.</p>