Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

PREVIOUS NEXT
Code Example
Python :: python while continue 
Python :: import yaml python3 
Python :: python tkinter label 
Python :: pandas head sort by colun name 
Python :: adding text cv2 
Python :: generate random integers 
Python :: pandas group by include nan 
Python :: how to check for a substring in python 
Python :: how to create dictionary in python from csv 
Python :: how to download a project from pythonanywhere 
Python :: opencv convert black pixels to white 
Python :: how to redirect in django 
Python :: hashlib sha 256 
Python :: remove specific character from object in pandas column using iloc 
Python :: numpy declare arraylength 
Python :: remove special characters from string in python 
Python :: python remove empty values from list 
Python :: python extract values that have different values in a column 
Python :: Program to find GCD or HCF of two numbers python 
Python :: cv2.flip 
Python :: python int16 
Python :: remove first item form dictionary python 
Python :: django pagination 
Python :: import discord python 
Python :: pytplot arc 
Python :: fibonacci series using dynamic programmig approach 
Python :: numpy diff 
Python :: hash table in python 
Python :: Setting up Colab for Kaggle Downloads 
Python :: beautifulsoup find 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =