Pandas: Divide column data by number if row of next column contains certain value
问题 I have a dataframe that consists of three columns qty unit_of_measure qty_cal 3 nodes nan 4 nodes nan 5 nodes nan 6 cores nan 7 nodes nan 10 cores nan 3 nodes nan I would like to add a condition to populate qty_cal . The condition is if unit_of_measure is equal to "nodes" populate the row value of qty into qty_cal If it's "cores" divide qty value by 16 and populate qty_cal The code I have tried is, if ppn_df['unit_of_measure'] == 'Nodes': ppn_df['qty'] elif ppn_df['unit_of_measure'] =='Cores'