I want to fill the value of the nan in the given value as following:
df = pd.DataFrame({'A' : ['aa', 'bb', 'cc', 'aa'],
'B': ['xx', 'yy', 'zz','xx'],
'C': ['2', '3','8', np.nan]})
print (df)
A B C
aa xx 2
bb yy 3
cc zz 8
aa xx NaN
Expected Output:
A B C
aa xx 2
bb yy 3
cc zz 8
aa xx 2
Since column A and B have value 2 in the third column, therefore last row should also have 2 in the C column.