[英]Replacing values from a dictionary to a multiindex dataframe
Have first dataframe (df1) as follows: 具有第一个数据帧(df1),如下所示:
Machine Product Value ...
Site TLA Date
TH ABC 08-Oct A10 RodA 35
09-Oct A10 RodA 20
10-Oct A11 RodB 22
…
ID ABC 09-Oct B5 HookY 28
08-Oct B8 HookZ 33
…
...some of whose columns (Machine and Value) need to be replaced with another dataframe (df2) as follows: ...其中的某些列(“机器”和“值”)需要用另一个数据帧(df2)替换,如下所示:
Machine Value
Site TLA Date
TH ABC 08-Oct A10 28
09-Oct A10 35
10-Oct A11 37
…
ID ABC 09-Oct B5 12
08-Oct B8 5
…
Tried to make a df2.to_dict(orient='index'), but stuck. 尝试制作df2.to_dict(orient ='index'),但卡住了。 How to map/replace this dictionary to the Machine, Value in df1?
如何将此字典映射到df1中的Machine,Value?
没有可复制的示例 ,很难确定,但是您应该能够做到
df1.loc[df2.index] = df2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.