glucopy.Gframe.quantile#

Gframe.quantile(per_day: bool = False, q: float = 0.5, interpolation: str = 'linear')[source]#

Calculates the quantile of the CGM values.

Parameters:
  • per_day (bool, default False) – If True, returns a pandas.Series with the quantile for each day. If False, returns the quantile for all days combined.

  • q (float, default 0.5) – Value between 0 and 1 for the desired quantile.

  • interpolation (str, default 'linear') –

    This optional parameter specifies the interpolation method to use, when the desired quantile lies between two data points i and j. Can be one of the following:

    • ’linear’: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.

    • ’lower’: i.

    • ’higher’: j.

    • ’nearest’: i or j, whichever is nearest.

    • ’midpoint’: (i + j) / 2.

Returns:

quantile – Quantile of the CGM values.

Return type:

float | pandas.Series

Examples

Calculating the median for the entire dataset:

In [1]: import glucopy as gp

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

In [3]: gf.quantile()
Out[3]: 134.0

Calculating the first quartile for the entire dataset:

In [4]: gf.quantile(q=0.25)
Out[4]: 93.0

Calculating the median for each day:

In [5]: gf.quantile(per_day=True)
Out[5]: 
Day
2020-11-27    279.0
2020-11-28    131.5
2020-11-29    131.5
2020-11-30    122.5
2020-12-01    144.0
              ...  
2021-03-14    138.0
2021-03-15    100.0
2021-03-16    158.0
2021-03-17    119.5
2021-03-18    182.0
Name: Quantile 0.5, Length: 112, dtype: float64