我有两个数据帧,如下所示。我需要一个结果数据,它将python中的数据帧1的周期累计和除以在pin、site和department处索引的数据帧2的周期累计和。你知道吗
Pin Site Department Period1 Period2 Period3 Period4
1001 L 42 1 0 2 3
1003 L 42 4 4 3 4
1002 R 45 4 5 2 4
Pin Site Department Period1 Period2 Period3 Period4
1002 R 45 5 6 5 5
1003 L 42 4 5 6 8
1001 L 42 1 2 4 5
Pin Site Department Period1 Period2 Period3 Period4
1001 L 42 1/1 (1+0)/(1+2) (1+0+2)/(1+2+4) (1+0+2+3)/(1+2+4+5)
1002 R 45 4/5 (4+5)/(5+6) (4+5+2)/(5+6+5) (4+5+2+4)/(5+6+5+5)
1003 L 42 4/4 (4+4)/(4+5) (4+4+3)/(4+5+6) (4+4+3+4)/(4+5+6+8)
不管两个数据帧中管脚的顺序如何,我都需要如上所述的结果数据帧。周期数将逐月增加。你知道吗
我认为需要^{} 将索引除以^{} 与^{} 对齐,最后为} :
MultiIndex
中的列添加^{编辑:
对于筛选出的值}
>1
需要反转条件-保留值<=1
-比较并检查每行是否有^{True
:相关问题 更多 >
编程相关推荐