def _transform(self, dfs): icustay_index = dfs['icustay_detail'].set_index('icustay_id') for df_name in ['chartevents', 'labevents', 'ioevents']: df = dfs[df_name] df['icustay_intime'] = icustay_index.loc[df['icustay_id'], 'icustay_intime'].values df = df[df['charttime'] > df['icustay_intime']] dfs[df_name] = df demo_history = DemographicTransform().transform(dfs['icustay_detail']) chart_history = ChartTransform().transform(dfs['chartevents']) lab_history = LabTransform().transform(dfs['labevents']) urine_history = UrineTransform().transform(dfs['ioevents']) all_history = from_chunks( [chart_history, lab_history, demo_history, urine_history]) all_history['charttime'] = big_dt_to_num(all_history['charttime']) all_history = all_history.sort_index( by=['subject_id', 'charttime']).reset_index(drop=True) all_history['charttime'] = num_to_big_dt(all_history['charttime']) all_history.drop_duplicates(inplace=True) all_history = all_history[[ 'subject_id', 'charttime', 'category', 'valuenum' ]] return all_history
def _transform(self, icustay_detail): df = icustay_detail computed_df = pd.DataFrame(index=df.index) computed_df['AGE'] = df['icustay_admit_age'].round() computed_df['GENDER'] = df['gender'].cat.set_categories(['F', 'M' ]).cat.codes computed_df['LOS'] = df['hospital_los'] / (60 * 24) computed_df['SURVIVAL'] = pd.to_timedelta(df['dod'] - df['icustay_intime']).dt.days computed_df['WEIGHT'] = df['weight_first'] computed_df['HEIGHT'] = df['height'].round(decimals=1) computed_df['SAPS'] = df['sapsi_first'] computed_df['SOFA'] = df['sofa_first'] computed_df.set_index( [df['subject_id'], big_dt_to_num(df['icustay_intime'])], inplace=True) stacked_ser = computed_df.stack(dropna=False) stacked_df = stacked_ser.reset_index() stacked_df.columns = [ 'subject_id', 'charttime', 'category', 'valuenum' ] stacked_df['charttime'] = num_to_big_dt(stacked_df['charttime']) return stacked_df
def _transform(self, icustay_detail): df = icustay_detail computed_df = pd.DataFrame(index=df.index) computed_df['AGE'] = df['icustay_admit_age'].round() computed_df['GENDER'] = df['gender'].cat.set_categories(['F', 'M']).cat.codes computed_df['LOS'] = df['hospital_los'] / (60 * 24) computed_df['SURVIVAL'] = pd.to_timedelta(df['dod'] - df['icustay_intime']).dt.days computed_df['WEIGHT'] = df['weight_first'] computed_df['HEIGHT'] = df['height'].round(decimals=1) computed_df['SAPS'] = df['sapsi_first'] computed_df['SOFA'] = df['sofa_first'] computed_df.set_index([df['subject_id'], big_dt_to_num(df['icustay_intime'])], inplace=True) stacked_ser = computed_df.stack(dropna=False) stacked_df = stacked_ser.reset_index() stacked_df.columns = ['subject_id', 'charttime', 'category', 'valuenum'] stacked_df['charttime'] = num_to_big_dt(stacked_df['charttime']) return stacked_df
def _transform(self, dfs): icustay_index = dfs['icustay_detail'].set_index('icustay_id') for df_name in ['chartevents', 'labevents', 'ioevents']: df = dfs[df_name] df['icustay_intime'] = icustay_index.loc[df['icustay_id'], 'icustay_intime'].values df = df[df['charttime'] > df['icustay_intime']] dfs[df_name] = df demo_history = DemographicTransform().transform(dfs['icustay_detail']) chart_history = ChartTransform().transform(dfs['chartevents']) lab_history = LabTransform().transform(dfs['labevents']) urine_history = UrineTransform().transform(dfs['ioevents']) all_history = from_chunks([chart_history, lab_history, demo_history, urine_history]) all_history['charttime'] = big_dt_to_num(all_history['charttime']) all_history = all_history.sort_index(by=['subject_id', 'charttime']).reset_index(drop=True) all_history['charttime'] = num_to_big_dt(all_history['charttime']) all_history.drop_duplicates(inplace=True) all_history = all_history[['subject_id', 'charttime', 'category', 'valuenum']] return all_history
def _transform(self, dfs): icustay_index = dfs["icustay_detail"].set_index("icustay_id") for df_name in ["chartevents", "labevents", "ioevents"]: df = dfs[df_name] df["icustay_intime"] = icustay_index.loc[df["icustay_id"], "icustay_intime"].values df = df[df["charttime"] > df["icustay_intime"]] dfs[df_name] = df demo_history = DemographicTransform().transform(dfs["icustay_detail"]) chart_history = ChartTransform().transform(dfs["chartevents"]) lab_history = LabTransform().transform(dfs["labevents"]) urine_history = UrineTransform().transform(dfs["ioevents"]) all_history = from_chunks([chart_history, lab_history, demo_history, urine_history]) all_history["charttime"] = big_dt_to_num(all_history["charttime"]) all_history = all_history.sort_index(by=["subject_id", "charttime"]).reset_index(drop=True) all_history["charttime"] = num_to_big_dt(all_history["charttime"]) all_history.drop_duplicates(inplace=True) all_history = all_history[["subject_id", "charttime", "category", "valuenum"]] return all_history
def _transform(self, icustay_detail): df = icustay_detail computed_df = pd.DataFrame(index=df.index) computed_df["AGE"] = df["icustay_admit_age"].round() computed_df["GENDER"] = df["gender"].cat.set_categories(["F", "M"]).cat.codes computed_df["LOS"] = df["los"] / (60 * 24) computed_df["SURVIVAL"] = pd.to_timedelta(df["dod"] - df["icustay_intime"]).dt.days computed_df["WEIGHT"] = df["weight_first"] computed_df["HEIGHT"] = df["height"].round(decimals=1) computed_df["SAPS"] = df["sapsi_first"] computed_df["SOFA"] = df["sofa_first"] computed_df.set_index([df["subject_id"], big_dt_to_num(df["icustay_intime"])], inplace=True) stacked_ser = computed_df.stack(dropna=False) stacked_df = stacked_ser.reset_index() stacked_df.columns = ["subject_id", "charttime", "category", "valuenum"] stacked_df["charttime"] = num_to_big_dt(stacked_df["charttime"]) return stacked_df