I've a dataframe and some of the values are missing. Luckily there are other rows which share the same attributes and values in other columns.
df = pd.DataFrame({'A': ('x','x','y'),
'B': (2,2,2),
'C':(3, np.nan, 7)})
A | B | C |
---|---|---|
x | 2 | 3 |
x | 2 | nan |
y | 2 | 7 |
Is there a fill method to populate the nan value in the 2nd row based on the common attributes of column A and B? i.e. nan should be filled to 3.
I've got a bigger dataframe so need a way of doing it systematically.