So basically I have to find the average for the first 168 values in the dataframe, then the next 168 and so on until the dataframe ends.
Asked
Active
Viewed 96 times
0
-
2[Calculate average of every x rows in a table and create new table](https://stackoverflow.com/questions/36810595/calculate-average-of-every-x-rows-in-a-table-and-create-new-table) – not_speshal Mar 30 '22 at 16:56
-
if you want the window centered on the left: `df.iloc[::-1].rolling(168).mean().iloc[::-1]` – mozway Mar 30 '22 at 16:59
1 Answers
0
Try:
results = []
idx = 168
while 168*(i+1) < len(df):
temp = df.iloc[168*i:168*(i+1)].mean()
results.append(mean)

le_camerone
- 630
- 5
- 17