vvcb / comorbidipy

Python package to calculate comorbidity scores including Charlson Comorbidity Score and Elixhauser Score and their weighted variants.
MIT License
10 stars 5 forks source link

Elixhauser with weighting="quan" returns key error: "quan" #4

Closed uhit-rob closed 6 months ago

uhit-rob commented 6 months ago

Description

When running the Elixhauser model, I get a KeyError: 'quan'

This happens when using the default weighting for the Elixhauser score as in: df_elix = comorbidity(df, score="elixhauser") #KeyError: 'quan'

It also happens when specifying the weighting="quan": df_elix = comorbidity(df, score="elixhauser", icd="icd10", variant="quan", weighting="quan") #KeyError: 'quan'

However, specifying a weighting="vw" works fine: df_elix = comorbidity(df, score="elixhauser", icd="icd10", variant="quan", weighting="vw") #works fine

What I Did

df_elix = comorbidity(df, score="elixhauser")
Traceback (most recent call last):

  Cell In[41], line 1
    df_elix = comorbidity(df, score="elixhauser")

  File C:\ProgramData\Anaconda3\envs\rob\Lib\site-packages\comorbidipy\calculator.py:142 in comorbidity
    dfp = _calculate_weighted_score(dfp, score_icd_variant, assign0, weighting)

  File C:\ProgramData\Anaconda3\envs\rob\Lib\site-packages\comorbidipy\calculator.py:32 in _calculate_weighted_score
    w = weights[param_score][weighting]

KeyError: 'quan'

df_elix = comorbidity(df, score="elixhauser", icd="icd10", variant="quan", weighting="quan")
Traceback (most recent call last):

  Cell In[38], line 1
    df_elix = comorbidity(df, score="elixhauser", icd="icd10", variant="quan", weighting="quan")

  File C:\ProgramData\Anaconda3\envs\rob\Lib\site-packages\comorbidipy\calculator.py:142 in comorbidity
    dfp = _calculate_weighted_score(dfp, score_icd_variant, assign0, weighting)

  File C:\ProgramData\Anaconda3\envs\rob\Lib\site-packages\comorbidipy\calculator.py:32 in _calculate_weighted_score
    w = weights[param_score][weighting]

KeyError: 'quan'