Answers for "set select group of columns to numeric pandas"

0

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)
Posted by: Guest on August-17-2020

Code answers related to "set select group of columns to numeric pandas"

Python Answers by Framework

Browse Popular Code Answers by Language