I have 2 dataframes which I have to join. I am trying to use merge on columns ID and STATUS. However the problem is if for a row status is NULL in df2 I want it to still match it based on just ID and bring the name. If STATUS has a value match it else match just the ID and bring the name.
mer_col_list = ['ID','STATUS']
df_out = pd.merge(df1,df2, on=mer_col_list, how='left')
df1 |ID | STATUS | NAME | |11 | ACTIVE | John | |22 | DORMANT| NICK | |33 | NOT_ACTIVE| HARRY|
df2 |ID | STATUS | BRANCH | |11 | DORMANT| USA | |11 | | USA | |22 | | UK | |33 | NOT_ACTIVE | AUS|
df_out: |ID| NAME | BRANCH| |11| JOHN | USA | |22| NICK | USA | |33|HARRY | AUS |