I have a dataframe like shown below:
df = pd.DataFrame({'person_id' :[1,1,1,2,2,2,2,2,2],'level_1': ['L1FR','L1Date','L1value','L1FR','L1Date','L1value','L2FR','L2Date','L2value'], 'val3':['Fasting','11/4/2005',1.33,'Random','18/1/2007',4.63,'Fasting','18/1/2017',8.63]})
But I would like to have my output dataframe as shown below:
Please note that concept_id = 123 indicates "Fasting" and 456 represents "Random". I have this information (keys) in another csv file. How do I link all this?
However, I managed to get till here:
d1 = s1[s1['level_1'].str.contains('Date')]
d2 = s1[