Python 熊猫减去两个不同大小的分组数据帧
我有两个数据帧: 我的库存解决方案(df1): 以及我做某事后的测量结果(df2): 我想用第二个数据帧(df2)中的每个度量值及其相应的库存解决方案(我从中获取样本)进行规范化Python 熊猫减去两个不同大小的分组数据帧,python,pandas,Python,Pandas,我有两个数据帧: 我的库存解决方案(df1): 以及我做某事后的测量结果(df2): 我想用第二个数据帧(df2)中的每个度量值及其相应的库存解决方案(我从中获取样本)进行规范化 有什么建议吗?在这篇文章的帮助下找到了答案: 我必须重置两个分组数据帧的索引,然后重新设置 df_initial = df_initial.reset_index().set_index(['pH','salt_conc']) df_second = df_second.reset_index().set_index
有什么建议吗?在这篇文章的帮助下找到了答案: 我必须重置两个分组数据帧的索引,然后重新设置
df_initial = df_initial.reset_index().set_index(['pH','salt_conc'])
df_second = df_second.reset_index().set_index(['pH','salt_conc'])
不,我可以做任何我想做的计算。查看df2的
.sub
方法上的level
参数。你可以在全世界广播
pH salt_conc id
5.5 0 8 20953.0
11 24858.0
200 3 20022.5
400 13 17691.0
20 18774.0
6.0 0 14 38639.0
200 1 37223.5
2 36597.0
7 37039.0
10 37088.5
15 35968.5
16 36344.5
17 34894.0
18 36388.5
400 9 33386.0
6.5 0 4 41401.5
12 44933.5
200 5 43074.5
400 6 42210.5
19 41332.5
df_initial = df_initial.reset_index().set_index(['pH','salt_conc'])
df_second = df_second.reset_index().set_index(['pH','salt_conc'])