我有一个DF,我想通过分组另一列将两个列组合或合并(我不确定正确的术语(。
这是我的DF
> print(BC_data)
Treatment Day LB PCA
Day2F1 Untreated 2 4400000 10900000
Day2F2 Untreated 2 5800000 5200000
Day2F3 Untreated 2 5700000 5900000
Day2F4 Metro 2 13100000 11500000
Day2F5 Metro 2 9600000 9100000
Day2F6 Metro 2 6900000 9700000
Day2F7 Pen 2 11400000 5100000
Day2F8 Pen 2 8000000 7300000
Day2F9 Pen 2 6300000 9300000
Day2F10 Rif 2 600000 4600000
Day2F11 Rif 2 400000 25000000
我想将列LB和PCA放在一个列中,然后按天分组。成为这样的东西
Treatment Day LB-PCA
Day2F1 Untreated 2 4400000
Day2F2 Untreated 2 5800000
Day2F3 Untreated 2 5700000
Day2F1 Untreated 2 10900000
Day2F2 Untreated 2 5200000
Day2F3 Untreated 2 5900000
......
有人可以帮忙吗?预先感谢
您只需两个步骤将记录加成。首先,选择原始DF中的所有记录,但重命名列LB作为LB-PCA。接下来,在原始DF中加入所有行,但现在使用PCA作为LB-PCA。最后,如有需要进行排序。