0

I tried to sum up multiple rows excluding Hour and Date row, But i get the error as

"Value Error: cannot join with no overlapping index names"

Exact data

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

Required output

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

I used the following script:

column_list = list(df_output)

column_list.remove('Hour')

df_output = df[df_output].sum(axis=1)
Mayank Porwal
  • 33,470
  • 8
  • 37
  • 58

1 Answers1

0

IIUC use:

df_output = df.groupby(['Input','Date'], as_index=False).sum()
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252