glucopy.Gframe.fd#
- Gframe.fd(per_day: bool = False, interval: list = [0, 70, 180], decimals: int = 2, count: bool = False)[source]#
Calculates the Frequency Distribution (Fi) for a given target range of glucose.
\[F_i = \frac{n_i}{N}\]\(n_i\) is the number of observations within the i-th interval.
\(N\) is the total number of observations.
- Parameters:
per_day (bool, default False) – If True, returns a
pandas.Series
with the FD for each day. If False, returns the FD for the entire dataset.interval (list of int|float, default [0,70,180]) – Interval of glucose concentration to calculate FD. 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.
decimals (int, default 2) – Number of decimal places to round to. Use None for no rounding.
count (bool, default False) – If True, returns the count of observations for each range. If False, returns the frequency of observations.
- Returns:
fd – Series of fd for each day.
- Return type:
Examples
Calculating the FD for the entire dataset and the default range (0,70,180):
In [1]: import glucopy as gp In [2]: gf = gp.data('prueba_1') In [3]: gf.fd() Out[3]: CGM (0.0, 70.0] 0.11 (70.0, 180.0] 0.61 (180.0, 445.0] 0.28 Name: CGM, dtype: float64
Calculating the FD for a custom range:
In [4]: gf.fd(interval=[0,70,150,180,230]) Out[4]: CGM (0.0, 70.0] 0.11 (70.0, 150.0] 0.48 (150.0, 180.0] 0.13 (180.0, 230.0] 0.17 (230.0, 445.0] 0.11 Name: CGM, dtype: float64
Calculating the FD for each day and the default range (0,70,180):
In [5]: gf.fd(per_day=True) Out[5]: Day 2020-11-27 [0.0, 0.0, 1.0] 2020-11-28 [0.03, 0.76, 0.21] 2020-11-29 [0.11, 0.57, 0.31] 2020-11-30 [0.05, 0.9, 0.05] 2020-12-01 [0.08, 0.71, 0.21] ... 2021-03-14 [0.02, 0.71, 0.27] 2021-03-15 [0.37, 0.32, 0.31] 2021-03-16 [0.02, 0.59, 0.39] 2021-03-17 [0.15, 0.81, 0.04] 2021-03-18 [0.02, 0.46, 0.52] Name: Time in Range, Length: 112, dtype: object