Iterate through excel file Pandas If NaN values in column L replace with value in column G If NaN values in column M replace with value in column H If NaN values in column N replace with value in column I If NaN values in column O replace with value in column J If NaN values in column P replace with value in column K
def get_name(row): if pd.isnull(row['L']): return row['G'] elif pd.isnull(row['M']): return row['H'] elif pd.isnull(row['N']): return row['I'] elif pd.isnull(row['O']): return row['J'] elif pd.isnull(row['P']): return row['K'] else: return row['L'] df.apply(get_name, axis=1)