I have a dataframe with 3-columns and I wanted to create a new column using values of column projection.
How the values should be picked from projection?--It should pick 3-consective values of projection year wise for ex - if you are creating a new column for year 2020 the value it should pick from 2021,2022,2023
I have tried below sql:
spark.sql(''' select serial_number,pit_pd_proj as proj1,year,lead(pit_pd_proj,3) over(partition by serial_number order by year) as proj2 from table where serial_number = 1 order by year''').show(50,truncate=False)
but this is not the complete answer
