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
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.

Nov 29, 2022 in Others 617 views

Generate a list for each means you want to calculate:

```x1, x2 = list(df.iloc[[0,1,2]].mean()), list(df.iloc[[9,10,11]].mean())
```

Or you could also generate a list of lists:

`x = [list(df.iloc[[0,1,2]].mean()), list(df.iloc[[9,10,11]].mean())]`
• 63,720 points

How can I copy from specific sheet in excel

You should use wb.Sheets("Name of sheet").Copy - ...READ MORE

In MS Excel what formula can be used to calculate growth when CAGR for the period is already given?

If those are true CAGR's, then just ...READ MORE

Hiding the formula bar in Excel for a specific file

No, you cannot. Unfortunately, altering the CustomUI file ...READ MORE

How do you populate a google sheets/excel column with cells from a column in another sheet in the same document?

You have two options on chronology: sheet-by-sheet =QUERY({Sheet1!X:Z; Sheet2!X:Z; ...READ MORE

how do i change string to a list?

suppose you have a string with a ...READ MORE

how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE