1
votes

Good evening all. I know that we can groupby multiple columns by just df.groupBy('col1,'col2','col3') I think that this grouping means that it first groups by col1 and for each member of col1 it groups by col2 and so on. If this is wrong just correct me, I basically started yesterday with PySpark because a university project.

I have the need to group the data by 4 members: 2 string columns and 2 time window.

df.groupBy('col1,'col2','1HourTimeWindow','15MinTimeWindow')

I'm aware that can do a groupBy with a window like this df.groupBy(window("timeCol", "1 hour")) but can't have more than 1 window in the same groupBy.

Any solution you can recommend to me would be awesome. Thanks in advance

1
Can you provide some sample data to better understand what you are trying to achieve. - Chris

1 Answers

0
votes

Solved by aggregating groupBy(col1, col2, 15Min) and after that grouping by 1 hour in subsequent tasks.