Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

PREVIOUS NEXT
Code Example
Python :: real time crypto prices python 
Python :: remove a character from a string python 
Python :: python program to count vowels in a string 
Python :: django unique_together 
Python :: flask render error template 
Python :: python get system information 
Python :: python read and delete line from file 
Python :: python read string from file 
Python :: how to check if all characters in string are same python 
Python :: pyqt5 line edit password input 
Python :: setting a condition for perfect square in python 
Python :: how to run for loop in python 
Python :: link python to python3 
Python :: python add 0 before number 
Python :: move mouse round in python 
Python :: The operands of the logical operators should be boolean expressions, but Python is not very strict. Any nonzero number is interpreted as True. 
Python :: time.ctime(os.path.getmtime phyton in datetime 
Python :: from random import choice 
Python :: python3 hello world 
Python :: python defaultdict example 
Python :: python dataframe shape 
Python :: does np.random.randint have a seed 
Python :: python find specific file in directory 
Python :: how to use variables in string in python 
Python :: python if string is null or whitespace 
Python :: pandas map multiple columns 
Python :: python count total no of word in a text 
Python :: flask server not reloading 
Python :: read a file and split the words python 
Python :: how to run python file from cmd in dockerfile 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =