I have the following framework:
import pandas as pd df = pd.DataFrame({'id':['a','b','c','d','e'], 'Sample1':[-14,-90,-90,-96,-91], 'Sample2':[-103,0,-110,-114,-114], 'Sample3':[1,2.3,3,5,6], }) df.set_index('id', inplace=True) df
It looks like this:
Sample1 Sample2 Sample3 id a -14 -103 1.0 b -90 0 2.3 c -90 -110 3.0 d -96 -114 5.0 e -91 -114 6.0
I would like to insert the following dictionary
mydict = { "Sample1": 0.023210000000000001, "Sample3": 0.039690000000000003, "Sample2": 0.05824 } mydict2 = { "Sample1": 0.7, "Sample3": 0.3, "Sample2": 0.8 }
as the last column with the names of the indices (rows) SRT and SRT2.
Yielding:
Sample1 Sample2 Sample3 id a -14 -103 1.0 b -90 0 2.3 c -90 -110 3.0 d -96 -114 5.0 e -91 -114 6.0 SRT 0.23 0.39 0.05 SRT2 0.7 0.3 0.8
How can i achieve this?