I have a dict of dataframes as shown below.
Currently what I am trying to do is replace values in column FR
of each of the dataframe and create a new column named unit
for each dataframe
Though I have a working code as shown below, not sure whether this is the best way to write it.
dataFramesDict['Cho'] = dataFramesDict['Cho'].replace({'FR' : {'Fasting' : 'Cholesterol Fasting', 'Random' : 'Cholesterol Random'}})
dataFramesDict['HDL'] = dataFramesDict['HDL'].replace({'FR' : {'Fasting' : 'Plasma fasting HDL cholesterol measurement', 'Random' : 'Plasma random HDL cholesterol measurement'}})
dataFramesDict['LDL'] = dataFramesDict['LDL'].replace({'FR' : {'Fasting' : 'Plasma fasting LDL cholesterol measurement', 'Random' : 'Plasma random LDL cholesterol measurement'}})
dataFramesDict['Tri'] = dataFramesDict['Tri'].replace({'FR' : {'Fasting' : 'Plasma fasting triglyceride measurement', 'Random' : 'Plasma random triglyceride measurement'}})
dataFramesDict['Cho']['unit'] = 'ml'
dataFramesDict['HDL']['unit'] = 'ml'
dataFramesDict['LDL']['unit'] = 'ml'
dataFramesDict['Tri']['unit'] = 'ml'
Please note the values to replace differs for each dataframe. However the original value is same across all dataframe as can be seen from the code
Can you let me know on how I can improve this further ?