glucopy.Gframe.tir#
- Gframe.tir(per_day: bool = False, interval: list = [0, 70, 180], percentage: bool = True, decimals: int = 2)[source]#
Calculates the Time in Range (TIR) for a given target range of glucose.
\[TIR = \frac{\tau}{T} * 100\]\(\tau\) is the time spent within the target range.
\(T\) is the total time of observation.
- Parameters:
per_day (bool, default False) – If True, returns a
pandas.Series
with the TIR for each day. If False, returns the TIR for the entire dataset.interval (list of int|float, default [0,70,180]) – Interval of glucose concentration to calculate \(\tau\). Can be a list of 1 number, in that case the time will be calculated below and above that number. It will always try to calculate the time below the first number and above the last number.
percentage (bool, default True) – If True, returns the TIR as a percentage. If False, returns the TIR as timedelta (\(TIR=\tau\)).
decimals (int, default 2) – Number of decimal places to round to. Use None for no rounding.
- Returns:
tir – Series of TIR.
- Return type:
Examples
Calculating the TIR for the entire dataset and the default range (0,70,180), this will return an array with the tir between 0 and 70, between 70 and 180 and above 180:
In [1]: import glucopy as gp In [2]: gf = gp.data('prueba_1') In [3]: gf.tir() Out[3]: ranges (0.0, 70.0] 11.24 (70.0, 180.0] 61.04 (180.0, 445.0] 27.72 Name: Time in Range, dtype: float64
Calculating the TIR for a custom range:
In [4]: gf.tir(interval=[0,70,150,180,230]) Out[4]: ranges (0.0, 70.0] 11.24 (70.0, 150.0] 47.70 (150.0, 180.0] 13.34 (180.0, 230.0] 16.96 (230.0, 445.0] 10.75 Name: Time in Range, dtype: float64
Calculating the TIR for each day and the default range (0,70,180):
In [5]: gf.tir(per_day=True) Out[5]: Day 2020-11-27 [0.0, 0.0, 100.0] 2020-11-28 [3.23, 76.84, 19.93] 2020-11-29 [11.66, 56.81, 31.53] 2020-11-30 [5.27, 89.47, 5.27] 2020-12-01 [8.36, 70.65, 21.0] ... 2021-03-14 [2.16, 71.79, 26.05] 2021-03-15 [36.36, 32.73, 30.91] 2021-03-16 [2.11, 59.73, 38.16] 2021-03-17 [14.74, 81.08, 4.17] 2021-03-18 [1.6, 45.04, 53.36] Name: Time in Range, Length: 112, dtype: object