pyamr.core.mari pyamr.core.mari =============== ===============

Classes

class pyamr.core.mari.MARI(groupby=['SPECIMEN', 'MICROORGANISM', 'LAB_NUMBER', 'SENSITIVITY'])[source]

Multiple Antimicrobial Resistance Index

Methods:

compute(dataframe, **kwargs)

Compute the Multiple Antimicrobial Resistance Index.

compute_v1(dataframe[, shift, period, ...])

Compute MARI v1

compute_v2(dataframe[, shift, period, ...])

Compute MARI v2.

compute_v3(dataframe[, shift, period, ...])

Compute MARI v3.

compute_v4(dataframe[, shift, period, ...])

Compute MARI v4.

grouping(dataframe, period, cdate)

Compute metric with independent groups.

rolling(dataframe, period, cdate[, shift])

Compute metric using rolling approach

compute(dataframe, **kwargs)[source]

Compute the Multiple Antimicrobial Resistance Index.

Parameters:
  • dataframe (pd.DataFrame) – A DataFrame with the susceptibility test interpretations as columns. The default strategies used (see below) expect the following columns [‘sensitive’, ‘intermediate’, ‘resistant’] and if they do not appear they weill be set to zeros.

  • shift (str) – Frequency value to pass to pd.Grouper.

  • period (str, int) – Window value to pass to pd.rolling.

  • cdate (string, default=None) – The column that will be used as date.

  • return_frequencies (boolean, default=True) – Whether to return the frequencies (isolates) or just the resistance index.

  • return_isolates (boolean, default=True) – Whether to return the resistance index for each individual isolate.

  • strategy (string or func, default=’hard’) – The method used to compute sari. The possible options are ‘soft’, ‘medium’ and ‘hard’. In addition, a function with the following signature func(dataframe, **kwargs) can be passed.

    1. soft as R / R+I+S

    2. medium as R / R+S

    3. hard as R+I / R+I+S

    4. other as R+0.5I / R+0.5I+S [Not yet]

  • **kwargs (arguments to pass the strategy function.)

Returns:

  • dataframe (pd.Series or pd.DataFrame) – The resistance index (pd.Series) or a pd.Dataframe with the resistance index (sari), the sums and the frequencies.

  • isolates (pd.DataFrame) – The resistance index and each of the sensitivity value counts for each individual isolate.

compute_v1(dataframe, shift=None, period=None, cdate=None, return_frequencies=True, return_isolates=True, **kwargs)[source]

Compute MARI v1

compute_v2(dataframe, shift=None, period=None, cdate=None, return_frequencies=True, return_isolates=True, **kwargs)[source]

Compute MARI v2.

compute_v3(dataframe, shift=None, period=None, cdate=None, return_frequencies=True, return_isolates=True, **kwargs)[source]

Compute MARI v3.

compute_v4(dataframe, shift=None, period=None, cdate=None, return_frequencies=True, return_isolates=True, **kwargs)[source]

Compute MARI v4.

grouping(dataframe, period, cdate)[source]

Compute metric with independent groups.

rolling(dataframe, period, cdate, shift=None)[source]

Compute metric using rolling approach

Examples using pyamr.core.mari.MARI

Multiple Resistance (MARI)

Multiple Resistance (``MARI``)