Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python pandas remove non-numeric characters from multiple columns

# Convert multiple columns to float when they contain non-numeric characters e.g. "R 5 000.00" -> 5000.00
df[['A','B','C','D']] = df[['A','B','C','D']].replace(regex=[r'D+'], value="").astype(float)
Comment

PREVIOUS NEXT
Code Example
Python :: select only some rows pandas 
Python :: dataframe get row by name 
Python :: extract url from page python 
Python :: ignoring warnings 
Python :: python subprocess with environment variables 
Python :: string startswith python 
Python :: how to check nth prime in python 
Python :: replace newline character in python 
Python :: pandas remove column 
Python :: dictionary python length 
Python :: python dictionary get key by value 
Python :: pandas check if value in column is in a list 
Python :: python get address of object 
Python :: python reverse array 
Python :: getting multiple selected value django 
Python :: apostrophe in python 
Python :: python datetime get all days between two dates 
Python :: raising exceptions in python 
Python :: python [remote rejected] master - master (pre-receive hook declined) 
Python :: django models using Value 
Python :: python get response from url 
Python :: how to load keras model from json 
Python :: install python packages behind proxy 
Python :: python remove last element from list 
Python :: if string contains list of letters python 
Python :: resize interpolation cv2 
Python :: count values in numpy list python 
Python :: python dictonary of dictonary 
Python :: python tabulate float format 
Python :: change directory in python script 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =