Consider the following dataframe
import pandas as pd df = pd.DataFrame({\'A\' : [1, 2, 3, 3, 4, 4, 5, 6, 7], \'B\' : [\'a\',\'b\',\'c\',\'
Or you can just using first(), by using the first , will give back the first notnull value, so the order of original input does not really matter.
first()
notnull
df.groupby(['A','B']).first() Out[180]: Col_1 Col_2 A B 1 a NaN 2 2 b A 2 3 c A 3 4 d B 3 5 e B 4 6 f NaN 4 7 g NaN 5