我是python的新手,我在StackOverflow中搜索我的案例,但是我找不到技术上的答案。我有很多英国人。你知道吗
我的问题是这样的,我有一个dataframe
:
df
BS N
BS1 - BS5 1
BS2 - BS7 2
BS1 - BS9 2
BS9 - BS1 1
我想自动生成新数据。我的预期结果如下:
New_BS BS1 - BS5 BS2 - BS7 BS1 - BS9 BS9 - BS1 Total
BS1-2 1 2 3
BS2-3 1 2 2 5
BS3-4 1 2 2 5
BS4-5 1 2 2 5
BS5-6 2 2 4
BS6-7 2 2 4
BS7-8 2 2
BS8-9 2 2
BS9-8 1 1
BS8-7 1 1
BS7-6 1 1
BS6-5 1 1
BS5-4 1 1
BS4-3 1 1
BS3-2 1 1
BS2-1 1 1
事先谢谢你帮助我
嗯-这是一个完全黑客-但它很有趣。。。你知道吗
输出
有大约1000种方法可以改善这一点-但这是一个好的开始。。。你知道吗
请注意,切片是数据集的一个非常重要的约束条件--您必须真正地修改它以使其成为动态的。你知道吗
相关问题 更多 >
编程相关推荐