Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Pandas conditional collumn

import pandas as pd
import numpy as np

df = pd.DataFrame({'Type':list('ABBC'), 'Set':list('ZZXY')})
df['color'] = np.where(df['Set']=='Z', 'green', 'red')
print(df)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Pandas #conditional #collumn
ADD COMMENT
Topic
Name
7+8 =