glucopy.Gframe.dt#

Gframe.dt(per_day: bool = False)[source]#

Calculates the Distance Travelled (DT).

\[DT = \sum_{i=1}^{N-1} | X_{i+1} - X_i |\]
  • \(X_i\) is the glucose value at time i.

  • \(N\) is the number of glucose readings.

Parameters:

per_day (bool, default False) – If True, returns a pandas.Series with the DT for each day. If False, returns the DT for the entire dataset.

Returns:

dt – Distance Travelled of Glucose Values.

Return type:

float | pandas.Series

Examples

Calculating the DT for the entire dataset (default):

In [1]: import glucopy as gp

In [2]: gf = gp.data('prueba_1')

In [3]: gf.dt()
Out[3]: 115800.0

Calculating the DT for each day:

In [4]: gf.dt(per_day=True)
Out[4]: 
Day
2020-11-27     104.0
2020-11-28    1134.0
2020-11-29    1104.0
2020-11-30     953.0
2020-12-01     932.0
               ...  
2021-03-14     877.0
2021-03-15    1176.0
2021-03-16     934.0
2021-03-17     824.0
2021-03-18     482.0
Name: Distance Travelled, Length: 112, dtype: float64