0

I have below dataframe, based on the visited date I need to create a new column allowed- If the customar visted within a week from last allowd week visit I have to mark allowed as NO (4th row 2020-01-09-2020-01-10 <7 ) and if it is more than 1 week allowed yes (3rd row 2020-01-09-2020-01-01 >7 )

Input DF

Customar  visited_date 

John       2020-01-01   
John       2020-01-05   
John       2020-01-09   
John       2020-01-10  
John       2020-01-17   

output DF

Customar  visited_date allowed 

John       2020-01-01   Yes
John       2020-01-05   No
John       2020-01-09   Yes
John       2020-01-10   No
John       2020-01-17   Yes  

I dont know how to calulate the colum value in runtime and used that in subsequent column calculation.

John
  • 1,531
  • 6
  • 18
  • 30
  • Does this answer your question? [Spark Window Functions - rangeBetween dates](https://stackoverflow.com/questions/33207164/spark-window-functions-rangebetween-dates) – Duelist May 07 '20 at 12:01
  • No, looks like that solution is not work for my usecase. – John May 11 '20 at 11:34

0 Answers0