Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to convert pandas price column to integer

# car_sales is my data, and price is its feature name
# anything that must be replaced is placed in square breackets in repalce
# where square brackets allow us to replace multiple characters
# it will replace thoses characters with empty string
# finally using dtypes, i am changing feature datatype to float
# in my case it is float, u may choose anything u want for example int
car_sales["Price"] = car_sales["Price"].str.replace("[$,]","").astype(float)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #pandas #price #column #integer
ADD COMMENT
Topic
Name
2+2 =