I have the following dataframe:
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
看起来像这样:
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
我想插入以下字典
mydict = {
"Sample1": 0.023210000000000001,
"Sample3": 0.039690000000000003,
"Sample2": 0.05824
}
mydict2 = {
"Sample1": 0.7,
"Sample3": 0.3,
"Sample2": 0.8
}
作为具有索引(行)名称 SRT 和 SRT2 的最后一列。输出为:
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
我该如何实现这个目标?