title: How to get data of previous row in Apache Spark
body: <p>Find previous month sale of each city from Spark Data frame </p>
  
  <pre><code>|City|     Month   |Sale|
  +----+----------- +----- +
  |  c1|    JAN-2017|  49 |
  |  c1|    FEB-2017|  46 |
  |  c1|    MAR-2017|  83 |
  |  c2|    JAN-2017|  59 |
  |  c2|    MAY-2017|  60 |
  |  c2|    JUN-2017|  49 |
  |  c2|    JUL-2017|  73 |
  +----+-----+----+-------
  </code></pre>
  
  <p>Required solution is</p>
  
  <pre><code>|City|     Month  |Sale   |previous_sale|
  +----+-----+-------+-------------+--------
  |  c1|    JAN-2017|  49|           NULL  |
  |  c1|    FEB-2017|  46|           49    |
  |  c1|    MAR-2017|  83|           46    |
  |  c2|    JAN-2017|  59|           NULL  |
  |  c2|    MAY-2017|  60|           59    |
  |  c2|    JUN-2017|  49|           60    |
  |  c2|    JUL-2017|  73|           49    |
  +----+-----+----+-------------+-----------
  </code></pre>
  
  <p>Please help me </p>