title: How to subtract row value from same column with previous year in pyspark?
body: <p>I have input data like this, with year name as a column, I want to subtract rating of past year from the present year with a new column as rating diff.</p>
  <pre><code>year,movie_name,language,rating  
  2019,akash,english,10   
  2019,antony,kannada,9   
  2020,akash,english,10   
  2020,antony,kannada,8
  </code></pre>
  <p>My result dataframe: which I want</p>
  <pre><code>year,movie_name,language,rating,rating_diff  
  2019,akash,english,10,-  
  2019,antony,kannada,9,-  
  2020,akash,english,10,0        
  2020,antony,kannada,8,-1
  </code></pre>
  <p>any help would be appreciated, thank you.</p>