[Solved] Search for column values in another column and assign a value from the next column from the row found to another column


You can try creating a dictionary from columns ['CheckStringHere','AssociatedValue1'] and replace values from StringToCheck column:

d = dict(df[['CheckStringHere','AssociatedValue1']].to_numpy())
df['FromNumber'] = df['StringToCheck'].replace(d)
#or df['FromNumber'] = df['StringToCheck'].map(d).fillna(df['FromNumber'])

print(df)
  StringToCheck FromNumber ToNumber CheckStringHere AssociatedValue1  \
0           10T         56                   AAA_ER                    
1          125T         16                 FGGR_DBC                    
2                                               10T               56   
3                                              125T               16   

  AssociatedValue2  
0                   
1                   
2               58  
3               24  

2

solved Search for column values in another column and assign a value from the next column from the row found to another column