pyamr.core.sart

Classes

class pyamr.core.sart.SART(column_specimen='SPECIMEN', column_microorganism='MICROORGANISM', column_antimicrobial='ANTIMICROBIAL', column_date='DATE', column_outcome='SENSITIVITY', column_resistance='RESISTANCE')[source]

Single Antimicrobial Resistance Trend.

Methods:

compute(dataframe[, period, shift, cdate, ...])

Computes Single Antimicrobial Resistance Index.

compute(dataframe, period='180D', shift='30D', cdate=None, return_objects=True, **kwargs)[source]

Computes Single Antimicrobial Resistance Index.

Todo

  • Add parameters to rolling!

  • Place value at the left, center, right of window?

  • Ensure that works when time gaps present!

  • Carefull with various indexes!

Parameters:
  • dataframe (pd.DataFrame) – It might receive two different types of DataFrames. The first option is a DataFrame with the raw susceptibility test records where the interpretation (‘sensitive’, ‘intermediate’, ‘resistant’) that will be used to compute the sari. The second option is a DataFrame with the sari values already computed.

  • 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 or just the resistance index.

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

The resistance index (pd.Series) or a pd.DataFrame with the resistance index (sari) and the frequencies.

Return type:

pd.Series or pd.DataFrame

Examples using pyamr.core.sart.SART

Step 01 - Compute AMR metrics

Step 01 - Compute AMR metrics