【发布时间】:2021-11-10 07:25:45
【问题描述】:
我试图总结多行,不包括小时和日期行,但我得到错误
“值错误:不能加入没有重叠的索引名称”
确切的数据
Hour Input Date Total DA DB CA CB X Y Z Z1 Z2
0 A 9/23/2021 14570 6816 636 6821 297 14213 335 9 13 0
0 B 9/23/2021 147864 63746 10186 63746 10186 147821 0 42 1 0
1 A 9/23/2021 126681 63180 191 63178 132 126606 34 36 5 0
1 B 9/23/2021 33119 1 16558 1 16559 33106 0 13 0 0
2 A 9/23/2021 11550 5398 653 5395 104 10991 549 2 8 0
2 B 9/23/2021 25197 0 12599 0 12598 25176 0 21 0 0
3 A 9/23/2021 259 0 157 0 102 204 55 0 0 0
3 B 9/23/2021 14379 0 7189 0 7190 14347 0 32 0 0
需要的输出
Hour Input Date Total DA DB CA CB X Y Z Z1 Z2
0 A 9/23/2021 162434 70562 10822 70567 10483 162034 335 51 14 0
1 A 9/23/2021 159800 63181 16749 63179 16691 159712 34 49 5 0
2 A 9/23/2021 36747 5398 13252 5395 12702 36167 549 23 8 0
3 A 9/23/2021 14638 0 7346 0 7292 14551 55 32 0 0
我使用了以下脚本:
column_list = list(df_output)
column_list.remove('Hour')
df_output = df[df_output].sum(axis=1)
【问题讨论】:
标签: python-3.x pandas dataframe