I am trying to create a window for a certain number of rows from the a CSV file like the following:
For instance, I need to count how many class in a window with size of 5 rows to get these results:
and to count how many class 1 and the other classes were in this window.
I tried to use Window function. I am trying with this code:
val winSpec = Window.rangeBetween(0, 5)
val dff = df.groupBy("time").agg(count("time").over(winSpec))
I would like to know how to control the rangeBetween
to start from the first row or any row and stop at certain row e.g. 10.