You chunkify your list and build averages over the chunks. The linked answer uses full chunks, I adapted it to build incremental ones:
Sliding avg via list comprehension:
# Inspiration for a "full" chunk I adapted: https://stackoverflow.com/a/312464/7505395
def overlappingChunks(l, n):
"""Yield overlapping n-sized chunks from l."""
for i in range(0, len(l)):
yield l[i:i + n]
somenums = [10406.19,10995.72,11162.55,11256.7,11634.98,12174.25,13876.47,
18491.18,16908,15266.43]
# avg over sublist-lengths
slideAvg5 = [ round(sum(part)/(len(part)*1.0),2) for part in overlappingChunks(somenums,6)]
print (slideAvg5)
Output:
[11271.73, 11850.11, 13099.36, 14056.93, 14725.22, 15343.27, 16135.52,
16888.54, 16087.22, 15266.43]
I was going for a partion of the list by incremental range(len(yourlist))
before averaging the partitions, but thats as full partitioning was already solved here: How do you split a list into evenly sized chunks? I adapted it to yield incremental chunks to apply it to your problem.
What partitions are used for avg-ing?
explained = {(idx,tuple(part)): round(sum(part)/(len(part)*1.0),2) for idx,part in
enumerate(overlappingChunks(somenums,6))}
import pprint
pprint.pprint(explained)
Output (reformatted):
# Input:
# [10406.19,10995.72,11162.55,11256.7,11634.98,12174.25,13876.47,18491.18,16908,15266.43]
# Index partinioned part of the input list avg
{(0, (10406.19, 10995.72, 11162.55, 11256.7, 11634.98, 12174.25)) : 11271.73,
(1, (10995.72, 11162.55, 11256.7, 11634.98, 12174.25, 13876.47)) : 11850.11,
(2, (11162.55, 11256.7, 11634.98, 12174.25, 13876.47, 18491.18)) : 13099.36,
(3, (11256.7, 11634.98, 12174.25, 13876.47, 18491.18, 16908)) : 14056.93,
(4, (11634.98, 12174.25, 13876.47, 18491.18, 16908, 15266.43)) : 14725.22,
(5, (12174.25, 13876.47, 18491.18, 16908, 15266.43)) : 15343.27,
(6, (13876.47, 18491.18, 16908, 15266.43)) : 16135.52,
(7, (18491.18, 16908, 15266.43)) : 16888.54,
(8, (16908, 15266.43)) : 16087.22,
(9, (15266.43,)) : 15266.43}