0

I am trying to create a window for a certain number of rows from the a CSV file like the following:

csv file

For instance, I need to count how many class in a window with size of 5 rows to get these results:

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.

  • Images are never good. try to add a small subset of data to the question and the expected output for that data. – philantrovert Jan 12 '18 at 14:16
  • Thanks for your note. Just wanted to give an idea of what I am looking for. So I am looking for how to create a window and controlling in its size then I can apply different operations based on the window's size. For instance, calss 1 repeated 3 times in the first window...etc – Foaad Mohamad Haddod Jan 12 '18 at 14:23

0 Answers0