Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

set select group of columns to numeric pandas

import pandas as pd

df = pd.DataFrame({'id':['a1', 'a2', 'a3', 'a4'],
  				   'A':['0', '1', '2', '3'],
                   'B':['1', '1', '1', '1'],
                   'C':['0', '1', '1', '0']})

df[['A', 'B', 'C']] = df[['A', 'B', 'C']].apply(pd.to_numeric, axis = 1)
 
PREVIOUS NEXT
Tagged: #set #select #group #columns #numeric #pandas
ADD COMMENT
Topic
Name
1+8 =