Answers for "set dtype for multiple columns pandas"

0

set dtype for multiple columns 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 dtype for multiple columns pandas"

Python Answers by Framework

Browse Popular Code Answers by Language