I have the following df in pyspark:
| id | col1 | col2 |
|---|---|---|
| on | true | true |
| off | false | true |
| on | true | false |
| off | false | true |
| on | true | false |
| off | false | true |
and I would like to summarize it as shown below:
| col | id | true | false |
|---|---|---|---|
| col1 | on | 3 | 0 |
| off | 0 | 3 | |
| col2 | on | 1 | 2 |
| off | 3 | 0 |
where the integers represent the count() of true and false instances. I've tried using unpivot unsuccessfully. Any help will be appreciated.