It should just be a matter of applying the correct set of transformations:
At this stage the data will look something like this:
But the real trick is going to be to flatten it and all that should be required is to group by weekOfYear and then select with that the sum of each column (S,M,T,W,T,F,S) and that last call would look something like this:
df.groupBy("weekOfYear")
.sum("Sun", "Mon","Tue", "Wed", "Thu", "Fri", "Sat")
--------------- UPDATE ------------
The solution involving sum(..) works if you have numerical data. However, if you have non-numerical data, we need a slightly different technique. In this case, we can still group by weekOfYear but instead of using sum(..) we can use agg(first(...), first(...), ...).
Thanks to Adam for the suggestion of using sum(..) and to @doug for the suggestion of using agg(first(..)).
As we were playing with this, I did put together a sample notebook that demonstrates both solutions .