Skip to content

Commit 551fe4d

Browse files
author
bnestor
committed
fixed codes in mimic_direct_extract.py so that .loc isn't called on None
1 parent b73cce6 commit 551fe4d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

mimic_direct_extract.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ def plot_variable_histograms(col_names, df):
999999
# TODO(mmd): Why does this work?
10001000
Y = Y.loc[shared_idx]
10011001
# Problems start here.
1002-
C = C.loc[shared_idx]
1002+
if C is not None: C = C.loc[shared_idx]
10031003
data = data[data.index.get_level_values('icustay_id').isin(set(shared_sub))]
10041004
data = data.reset_index().set_index(ID_COLS)
10051005

@@ -1014,23 +1014,24 @@ def plot_variable_histograms(col_names, df):
10141014

10151015
Y.columns = Y.columns.str.lower()
10161016
out_names = list(Y.columns.values[3:])
1017-
C.columns = C.columns.str.lower()
1018-
icd_names = list(C.columns.values[1:])
1017+
if C is not None:
1018+
C.columns = C.columns.str.lower()
1019+
icd_names = list(C.columns.values[1:])
10191020
data.columns = data.columns.str.lower()
10201021
static_names = list(data.columns.values[3:])
10211022

10221023
print('Shape of X : ', X.shape)
10231024
print('Shape of Y : ', Y.shape)
1024-
print('Shape of C : ', C.shape)
1025+
if C is not None: print('Shape of C : ', C.shape)
10251026
print('Shape of static : ', data.shape)
10261027
print('Variable names : ', ",".join(var_names))
10271028
print('Output names : ', ",".join(out_names))
1028-
print('Ic_dfD9 names : ', ",".join(icd_names))
1029+
if C is not None: print('Ic_dfD9 names : ', ",".join(icd_names))
10291030
print('Static data : ', ",".join(static_names))
10301031

10311032
X.to_hdf(os.path.join(outPath, dynamic_hd5_filt_filename), 'vitals_labs')
10321033
Y.to_hdf(os.path.join(outPath, dynamic_hd5_filt_filename), 'interventions')
1033-
C.to_hdf(os.path.join(outPath, dynamic_hd5_filt_filename), 'codes')
1034+
if C is not None: C.to_hdf(os.path.join(outPath, dynamic_hd5_filt_filename), 'codes')
10341035
data.to_hdf(os.path.join(outPath, dynamic_hd5_filt_filename), 'patients', format='table')
10351036
#fencepost.to_hdf(os.path.join(outPath, dynamic_hd5_filt_filename), 'fencepost')
10361037

0 commit comments

Comments
 (0)