Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

new column with multiple conditions

def conditions(s):
    if (s['col1'] > 20) or (s['col2'] == 0) or (s['col3'] > 100):
        return 1
    elif (s['col1'] == True:
    else:
        return 0
df['your_new_col'] = df.apply(conditions, axis=1)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #column #multiple #conditions
ADD COMMENT
Topic
Name
5+6 =