Commited changes to make the code more efficient and reduce complexity. #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As an enthusiastic aspirant for GSOC 2020, I would like to contribute in this project. Below are a few changes which I believe would make the code simpler and efficient. THANK YOU!!
-> if dt.get(df.iloc[i]['patientunitstayid'], [0,0])[0]==0: Updated to- if dt.get(df.iloc[i]['patientunitstayid'])=="None": as get() will return "None" by default if key doesn't match.
-> drugs = df.iloc[i]['drugname'].split()
drugs = [drug.lower() for drug in drugs]
Updated to- drug = (df.iloc[i]['drugname'].split()[0]).lower() as feverDrugs[] contains only the first name of medicines. According to the original code, the post fix names of each medicine would be considered as different medicines. Example: "WARFARIN SODIUM" would be split into 2 different drugs namely "WARFARIN" and "SODIUM", which is ambiguous and is only adding extra For loops to match the first name with the drugs in feverDrugs[]
-> if sum([int(feverDrug==drug) for feverDrug in feverDrugs for drug in drugs])>0:
Updated to- if drug in feverDrugs: (for obvious reasons after the previous changes)
-> [1, df.iloc[i]['drugstartoffset']] Updated To- [df.iloc[i]['drugstartoffset']]
as 1 is no longer requried to be one of the values of the key for comparison in the IF statement