I want to forward fill if there is some value available in past 10 days based on today's date.
I can't use below code for cases when there is missing date for some id.

df.withColumn('fill_fwd',F.last("columnToFill", True).over(Window.partitionBy("id").orderBy('date').rowsBetween(-10, 0))

is there any other way? I also don't want to create rows for missing date if possible.

0

There are 0 best solutions below