EmmaRocheteau / TPC-LoS-prediction

This repository contains the code used for Temporal Pointwise Convolutional Networks for Length of Stay Prediction in the Intensive Care Unit (https://dl.acm.org/doi/10.1145/3450439.3451860).
https://dl.acm.org/doi/10.1145/3450439.3451860
MIT License
76 stars 25 forks source link

KeyError: '[141939 142056 142476 142521 142560 146391 147447 149039 149606 153006\n 160529 162431 166572 166709 167391 167417 171174 175528 177651 178069\n 178858 179142 179554] not in index' #2

Closed pervaizniazi closed 3 years ago

pervaizniazi commented 3 years ago

Hi, I am getting following error while running the command: python -m eICU_preprocessing.run_all_preprocessing

/opt/conda/lib/python3.6/runpy.py:85: DtypeWarning: Columns (3) have mixed types.Specify dtype option on import or set low_memory=False. exec(code, run_globals) Traceback (most recent call last): File "/opt/conda/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Code/TPC-LoS-prediction-master/eICU_preprocessing/run_all_preprocessing.py", line 19, in timeseries_main(eICU_path, test=False) File "/Code/TPC-LoS-prediction-master/eICU_preprocessing/timeseries.py", line 228, in timeseries_main gen_timeseries_file(eICU_path, test) File "/Code/TPC-LoS-prediction-master/eICU_preprocessing/timeseries.py", line 166, in gen_timeseries_file merged = timeseries_lab.loc[patient_chunk].append(timeseries_resp.loc[patient_chunk], sort=False) File "/opt/conda/lib/python3.6/site-packages/pandas/core/indexing.py", line 879, in getitem return self._getitem_axis(maybe_callable, axis=axis) File "/opt/conda/lib/python3.6/site-packages/pandas/core/indexing.py", line 1099, in _getitem_axis return self._getitem_iterable(key, axis=axis) File "/opt/conda/lib/python3.6/site-packages/pandas/core/indexing.py", line 1037, in _getitem_iterable keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False) File "/opt/conda/lib/python3.6/site-packages/pandas/core/indexing.py", line 1240, in _get_listlike_indexer indexer, keyarr = ax._convert_listlike_indexer(key) File "/opt/conda/lib/python3.6/site-packages/pandas/core/indexes/multi.py", line 2397, in _convert_listlike_indexer raise KeyError(f"{keyarr[mask]} not in index") KeyError: '[141939 142056 142476 142521 142560 146391 147447 149039 149606 153006\n 160529 162431 166572 166709 167391 167417 171174 175528 177651 178069\n 178858 179142 179554] not in index' ==> Removing the stays.txt file if it exists...

==> Removing the preprocessed_timeseries.csv file if it exists... ==> Loading data from timeseries files... ==> Reconfiguring lab timeseries... ==> Reconfiguring respiratory timeseries... ==> Reconfiguring nurse timeseries... ==> Reconfiguring aperiodic timeseries... ==> Reconfiguring periodic timeseries... ==> Starting main processing loop...

Any idea how to fix this?

EmmaRocheteau commented 3 years ago

Hi!

Sorry it took me a couple of days to get to this.

Have you checked that the timeseries{...}.csv files are correct? For example if you open timeseriesaperiodic.csv does it have the patient id 141939 in it?

If these patient ids are indeed present in the timeseries{...}.csv files, it might be worth checking that the version of pandas is the same as in the requirements.txt file.

Let me know if this helps.

Emma

pervaizniazi commented 3 years ago

Hi ! Thank you for the reply. Yes, it was the issue with pandas version. Thanks