'Combining two indexes in a Pandas Dataframe

enter image description here

I have the above dataframe and i would like to combine the two indexes so that only 1 remains and it is the addition of the indexes.



Solution 1:[1]

Get the 2 lines in the dataset and apply the logic below:

list1 = [1,0,1,0,1]
list2 = [0,2,0,2,0]
list3 = [x or y for x, y in zip(list1, list2)]

print(list3)

Output: [1, 2, 1, 2, 1]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LBJ