How can I use function based on IF ELSE condition to use following result?
Condition are based on 'Priority' columns and return values from 'Check' column to new Column Conditions: if Priority == CP 1 or CP 2: return values from 'Check' to Column 'Final' else: return: 'No' to Column 'Final' I tried and unable to return values from the column 'Check'
CodePudding user response:
you can implement if-else condition using np.where
import numpy as np
# check for conditions, Priority being CP1 or CP2
# when true return df['Check']
# else No
df['Final'] = np.where(df['Priority'].isin(['CP 1','CP 2']), df['Check'], 'No')
PS: if you post the data as a code or text, i would have been able to share the result