Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script crashes if there are 0 inpatient records w/out discharge date #26

Closed
christopherpickering opened this issue Apr 9, 2020 · 3 comments · Fixed by #27
Closed

Script crashes if there are 0 inpatient records w/out discharge date #26

christopherpickering opened this issue Apr 9, 2020 · 3 comments · Fixed by #27

Comments

@christopherpickering
Copy link

Hi,

Thanks for the script!

When I run a claims file that is only outpatient data (all inpatient = FALSE), or an inpatient without a discharge date the script produces this error:

Traceback (most recent call last):
  File "run_cv19index.py", line 6, in <module>
    cv19index.predict.main()
  File "c:\Users\chris-pickering\Documents\Projects\cv19index\cv19index\cv19index\predict.py", line 445, in main
    do_run_claims(args.demographics_file, args.claims_file, args.output_file, args.model, args.as_of_date, args.feature_file)
  File "c:\Users\chris-pickering\Documents\Projects\cv19index\cv19index\cv19index\predict.py", line 416, in do_run_claims
    input_df = preprocess_xgboost(claim_df, demo_df, asOfDate)
  File "c:\Users\chris-pickering\Documents\Projects\cv19index\cv19index\cv19index\preprocess.py", line 79, in preprocess_xgboost
    inpatient_days = pd.Series((inpatient_rows['dischargeDate'].dt.date - inpatient_rows['admitDate'].dt.date).dt.days, index=claim_df['personId'])
  File "C:\Users\chris-pickering\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\generic.py", line 4372, in __getattr__
    return object.__getattribute__(self, name)
  File "C:\Users\chris-pickering\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\accessor.py", line 133, in __get__
    accessor_obj = self._accessor(obj)
  File "C:\Users\chris-pickering\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\indexes\accessors.py", line 325, in __new__
    raise AttributeError("Can only use .dt accessor with datetimelike "
AttributeError: Can only use .dt accessor with datetimelike values

To resolve, I changed on claim to be inpatient=TRUE and added a discharge date of today.

Can we update the script for this scenario?

Thanks!
Christopher

@DaveDeCaprio
Copy link
Contributor

Yes, I see that would be the case. Thanks for pointing this out! We will get a fix in.

@DaveDeCaprio
Copy link
Contributor

This is fixed in master. Thanks again for finding it. Will go out in the next release.

@christopherpickering
Copy link
Author

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants