Here is a minimal example:
import pandas as pd
df = pd.DataFrame({'x': [0, 0, np.NaN, 1], 'y': [1, 0, 0, np.NaN], 'z': [np.NaN, 1, 1, 0]}, dtype = int, index = ['a', 'a', 'b', 'b'])
x y z
a 0 1 NaN
a 0 0 1
b NaN 0 1
b 1 NaN 0
Values can only be 0, 1, or NaN. I want to add rows that have the same index, ignoring NaN values. The result would be here:
x y z
a 0 1 1
b 1 0 1
The way I am doing it:
df.max(level = 0)
Is there a faster way?