Dear Friends: I'm having trouble using Python to determine the mean of certain rows from an excel sheet. In particular, starting with the first three rows and going to the next three and so forth, I would want to calculate the mean for each set of three rows. 156 rows of data are on my excel sheet. This is how my data sheet looks:
And this is my code:
import numpy
import pandas as pd
df = pd.read_excel("My Excel.xlsx")
x = df.iloc[[0,1,2], [9,10,11]].mean()
print(x)
In summary, I'm attempting to use a single line of code or some sort of index to get the means of Part 1 Measurements 1 (rows 1, 2, and 3), and Part 2 Measurements 1 (rows 9, 10, and 11). Two lists of numbers, one representing the mean of Part 1 Measurement 1 (rows 1, 2, and 3), and the other representing the mean of Part 2 Measurements 1 are what I'm anticipating receiving (rows 10,11,12). Additionally, I am aware that Python considers the first row as 0. The index must take the form n+1.