Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

switch cases pandas

df['new_column'] = np.where(df['col2']<9, 'value1',
                   np.where(df['col2']<12, 'value2',
                   np.where(df['col2']<15, 'value3', 'value4')))
Source by www.statology.org #
 
PREVIOUS NEXT
Tagged: #switch #cases #pandas
ADD COMMENT
Topic
Name
3+5 =