I need help in writing a code that will group the columns and convert the data as mentioned above.
I have data with 3000 columns, each containing a value of 0 or 1. I need to group these columns into weeks, with the columns from 1-7 in week 1, 8-14 in week 2, and so on. If any of the columns in a given week have a value of 1, then the week should be given a value of 1, otherwise it should be given a value of 0.
I need help writing a code to accomplish this.
Input Data
| days | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|--------|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|
| value | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
Output Data
| weeks | week_1 | week_2 |
|-------|--------|--------|
| value | 0 | 1 |