Scale(Normalise) a column in SPARK Dataframe - Pyspark
<p>I am trying to normalize a column in SPARK DataFrame using python.</p>

<p>My dataset:</p>

<pre><code>--------------------------
userID|Name|Revenue|No.of.Days|
--------------------------
1      A     12560    45
2      B     2312890  90
.      .       .       .
.      .       .       .
.      .       .       .
--------------------------
</code></pre>

<p>In this dataset, except the userID and Name, I have to normalize the Revenue and No.of Days.</p>

<p>The output should look like this</p>

<hr>

<pre><code>userID|Name|Revenue|No.of.Days|
--------------------------
1      A     0.5     0.5
2      B     0.9       1
.      .       1     0.4
.      .     0.6       .
.      .       .       .
--------------------------
</code></pre>

<p>The formula used to calculate or normalizing the values in each column is</p>

<pre><code>val = (ei-min)/(max-min)
ei = column value at i th position
min = min value in that column
max = max value in that column
</code></pre>

<p>How can I do this in easy steps using PySpark? </p>