Calculation of forward average (Piyolog sleep time)

Introduction

This is a continuation of Visualize the export data of Piyolog. Add the forward average to the graph generated last time.

Added part

get_array_average


def get_array_average(array, span):

    ave = 0
    ret_array = []

    for index, item in enumerate(array):
        if index <= len(array) - span:
            for i in range(span):
                ave += array[index + i]
            ret_array.append(round(ave / span, 1))
            ave = 0

    return ret_array

result

This time, we are calculating the forward average for 10 days. You can see that the sleep time is decreasing as you grow up. 20200509_135535.png

Recommended Posts

Calculation of forward average (Piyolog sleep time)
Calculation of time series customer loyalty
I compared the calculation time of the moving average written in Python
measurement of time
Measurement of execution time
Calculation of satellite orbit LST using python (true sun, average sun)