I have a dataframe like as shown below
df = pd.DataFrame({'Credit_History':['Yes','ABC','DEF', 'JKL'],
'Loan_Status':['T1','T2',np.nan,np.nan],
'subject_status':['DUMMA','CHUMMA',np.nan,np.nan],
'test_status':['test',np.nan,np.nan,np.nan]})
My objective is to fill the missing values with the corresponding credit_history
value across all rows and columns
I tried the below but it doesn't work
cols = ['Loan_Status','subject_status','test_status']
df[cols] = df[cols].fillna(df['Credit_History'])
I expect my output to be like as shown below. Basically, whichever row is missing, it should pick the corresponding value from credit_history
column