glucopy.Gframe.iqr#

Gframe.iqr(per_day: bool = False, interpolation: str = 'linear')[source]#

Calculates the Interquartile Range (IQR) of the CGM values.

Parameters:
  • per_day (bool, default False) – If True, returns a pandas.Series with the interquartile range for each day. If False, returns the interquartile range for the entire dataset.

  • 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:

iqr – Interquartile range of the CGM values.

Return type:

float | pandas.Series

Examples

Calculating the interquartile range for the entire dataset:

In [1]: import glucopy as gp

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

In [3]: gf.iqr()
Out[3]: 95.0

Calculating the interquartile range for each day:

In [4]: gf.iqr(per_day=True)
Out[4]: 
Day
2020-11-27     36.00
2020-11-28     64.50
2020-11-29    109.25
2020-11-30     39.25
2020-12-01     63.50
               ...  
2021-03-14     71.00
2021-03-15    143.50
2021-03-16     68.00
2021-03-17     60.50
2021-03-18     90.50
Name: Interquartile Range, Length: 112, dtype: float64