You can just pass the filter_col
into loc
:
filter_col = [col for col in t18_df if col.startswith('aum_')]
# zero out filter_col
t18_df.loc[t18_df['AUM'] < 0, filter_col] = 0
# zero out AUM itself
t18_df.loc[t18_df['AUM'] < 0, 'AUM'] = 0
# also
# t18_df['AUM'] = t18_df['AUM'].clip(0)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…