If column A has sentence: hb_mumbai refinery data. So i need to check if column A contains hb_mumbai then update the value of column B to : hb_mumbai
I have tried to implement it using contains function but it did not produced desired output.
if df['A'].str.contains('hb_mumbai'): df['B']=='hb_mumbai' Actual result: Value of column B is not getting updated Desired result: Value of column B should get updated.
numpy.wherefor this which is more efficient ,df.A = np.where(df.B.str.contains('hb_mumbai'),'hb_mumbai', df.A). Doimport numpy as npalso.