title: How to convert my data format to one accepted by ML's ALS
body: <p>I have this problem time to time and I end up using <code>RDD</code>s to solve it, and I was wondering if it is possible to achieve it with <code>Spark 2.0</code>. The way how products' scores  is normally stored is (<code>userid</code>, <code>product1</code>, ... , <code>productn</code>). However, <code>ALS</code> instantiation requires you to set the user column, the item column and the rating column. So, is there any way to achieve this transformations using <code>DataFrames</code> transformations and/or SQL sentences?</p>
  
  <p>To illustrate:
  Source <code>DataFrame</code>:</p>
  
  <pre><code>+---+-----------------+------------------+
  | id|         product1|          product2|
  +---+-----------------+------------------+
  |  2|4.285714285714286| 4.785714285714286|
  |  3|              5.0|               5.0|
  |  4|3.857142857142857|3.2142857142857144|
  |  5|3.142857142857143|1.5714285714285714|
  +---+-----------------+------------------+
  </code></pre>
  
  <p>Resulting <code>DataFrame</code>:</p>
  
  <pre><code>+------+---------+------------------+
  |userid|productid|             score|
  +------+---------+------------------+
  |   2.0|      2.0| 4.785714285714286|
  |   2.0|      1.0| 4.285714285714286|
  |   3.0|      1.0|               5.0|
  |   3.0|      2.0|               5.0|
  +------+---------+------------------+
  </code></pre>