I have a DataFrame shown below:
df = {'col1': {0: 'v1',
1: 'v2',
2: 'v3',
3: 'v4'},
'col2': {0: np.nan,
1: 13,
2: 76,
3: 2},
'col3': {0: np.nan,
1: 91,
2: 3,
3: 33},
'col4': {0: np.nan,
1: 9,
2: 47,
3: 62}}
I want to replace all "nan" values associated with "Val1" of col1 by adding values associated to "val2" and "val4" and impute it in col2,col3 and col4.
So expected output will look like this -
| col1 col2 col3 col4
---------------------------------------
0 | "v1" 15 124 71
1 | "v2" 13 91 9
2 | "v3" 76 3 47
3 | "v4" 2 33 62