I have a dataset like this
data = {'weight': ['NaN',2,3,4,'NaN',6,7,8,9,'NaN',11,12,13,14,15],
'MI': ['NaN', 21, 19, 18, 'NaN',16,15,14,13,'NaN',11,10,9,8,7]}
df = pd.DataFrame(data, index= ['group1', "gene1", "gene2", 'gene3',
'group2', "gene1", 'gene21', 'gene4', 'gene7', 'group3',
'gene2', 'gene10', 'gene3', 'gene43', 'gene1'])
I need to stack it to gene by group dataframe with MI values. If there are no gene values for particular group the imputated value should be 0.1. 'weights' column should be removed. The final dataframe should look like this
source https://stackoverflow.com/questions/74481613/how-to-unstack-a-dataset-to-a-certain-dataframe
Comments
Post a Comment