title: Convert Array into dataframe with columns and index in Scala
body: <p>Initially I have a matrix  </p>
  
  <pre><code> 0.0  0.4  0.4  0.0 
   0.1  0.0  0.0  0.7 
   0.0  0.2  0.0  0.3 
   0.3  0.0  0.0  0.0
  </code></pre>
  
  <p>The matrix <code>matrix</code> is converted into a <code>normal_array</code> by  </p>
  
  <pre><code>`val normal_array = matrix.toArray`  
  </code></pre>
  
  <p>and I have an array of string</p>
  
  <pre><code>inputCols : Array[String] = Array(p1, p2, p3, p4)
  </code></pre>
  
  <p>I need to convert this matrix into a following data frame. <em>(Note: The number of rows and columns in the matrix will be the same as the length of the <code>inputCols</code>)</em></p>
  
  <pre><code>index  p1   p2   p3   p4
   p1    0.0  0.4  0.4  0.0 
   p2    0.1  0.0  0.0  0.7 
   p3    0.0  0.2  0.0  0.3 
   p4    0.3  0.0  0.0  0.0
  </code></pre>
  
  <p>In python, this can be easily achieved by <code>pandas</code> library.   </p>
  
  <pre><code>arrayToDataframe = pandas.DataFrame(normal_array,columns = inputCols, index = inputCols)
  </code></pre>
  
  <p>But how can I do this in <code>Scala</code>?</p>