'how to creat column with sub colum (under) in pandas
I have a long data sheet with many questions. There are many questions with two or more answers, like below: [![question format in sheet][1]][1]
Q:1 is there electricity in your home Q:2 What are the electric appliances in your home
yes tv
yes fridge
no laptop
no computer
yes tv
yes laptop
I want the output result as below: [![answer][2]][2]
Q:1 is there electricity in your home Q:2 What are the electric appliances in your home
total yes no total tv fridge laptop computer
6 4 2 6 2 1 2 1
I want an additional column of "total" and a "total of Yes or No or TV" in other columns as well, as shown in the photo above. Thank you all for your help.
Edit: The first column is a question (Q1 & Q2). The below rows are the answers from different people in the survey. It is a sample for your understanding.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
