Fill na values in one pandas dataframe's column using another, but using column indices, not names

Use the iloc accessor. Slice using index range to avaoid running into issues.

Sample

df1 = pd.DataFrame({'sub_name': [np.nan,'AAB','AAC','BAA','CAA','CAC','CAD','CAE','EAA', 'FAA'], 
'val_1': [2,4,8,7,4,6,2,3,8,3], 
'A':[208,208,208,210,213,213,213,213,222,223]})


df1.iloc[0:1,0].fillna(df1.iloc[0,1])




   sub_name  val_1    A
0        2      2  208
1      AAB      4  208
2      AAC      8  208
3      BAA      7  210
4      CAA      4  213
5      CAC      6  213
6      CAD      2  213
7      CAE      3  213
8      EAA      8  222
9      FAA      3  223

You could use bfill with iloc

import pandas as pd
import numpy as np
df = pd.DataFrame({'a':[np.nan,2,3],'b':[100,200,300],'c':['x','y','z']})

df.iloc[:,:2] = df.iloc[:,:2].bfill(axis=1)

print(df)

Output

     a      b  c
0  100.0  100.0  x
1    2.0  200.0  y
2    3.0  300.0  z