I'm extracting certain columns from an Excel spreadsheet, then I'd like to get the mean of multiple columns based on their names, then insert that calculated mean column after each section that was averaged.
I have the following code to extract certain columns:
dataIn = pd.read_excel('mySpreadsheet.xlsx')
dataExtract = dataIn.filter([
"3.2.6 Programming with Karel Quiz",
"5.1.2 Hello World Quiz",
"5.1.4 Your Name and Hobby",
"5.2.2 Variables Quiz",
"5.2.4 Daily Activities",
"5.3.2 User Input Quiz",
"5.3.4 Dinner Plans",
"5.4.2 Basic Math in JavaScript Quiz",
"5.4.6 T-Shirt Shop",
"5.4.7 Running Speed",
"5.5.2 JavaScript Graphics Quiz",
"5.5.8 Flag of the Netherlands",
"5.5.9 Snowman",
"5.6.2 Using RGB to Create Colors",
"5.6.4 Exploring RGB",
"5.6.5 Making Yellow",
"5.6.6 Rainbow",
"5.6.7 Create a Color Image!",
"6.1.1 Ghost",
"6.1.2 Fried Egg",
"6.1.3 Draw Something",
"6.1.4 JavaScript and Graphics Quiz"
], axis=1)
dataExtract.to_excel('output/newSpreadsheet.xlsx')
I'd like to end up with the following dataframe:
"5.1.2 Hello World Quiz",
"5.1.4 Your Name and Hobby",
"5.1 Average",
"5.2.2 Variables Quiz",
"5.2.4 Daily Activities",
"5.2 Average",
"5.3.2 User Input Quiz",
"5.3.4 Dinner Plans",
"5.3 Average"
etc.
What is the best way to accomplish this?