如果满足 np.where,则将新列乘以数字

Multiplying a new column by a number if the np.where is met

如果满足条件,我正在尝试将此列乘以一个数字。如果是,我希望 august_report['Monthly Recurring Charge'] 列乘以一个数字,例如 20.

august_report['Activation Commission'] = np.where((august_report['Line activity'] == 'Activation')&(august_report['Activation type'] == 'Lease'),np.multiply(august_report['Monthly Recurring Charge'],20))

IIUC,这就是你要找的

august_report['Activation Commission'] = np.where((august_report['Line activity'] == 'Activation')&(august_report['Activation type'] == 'Lease'),august_report['Activation Commission']*august_report['Monthly Recurring Charge'],"a number")

IIUC 这就是您要查找的内容:

august_report['Activation Commission'] = np.where((august_report['Line activity'] == 'Activation')&(august_report['Activation type'] == 'Lease'),august_report['Monthly Recurring Charge']*20, 'condition not met'))

如果您想在不满足条件时保留原始值,请将 'condition not met' 替换为 august_report['Monthly Recurring Charge']