Manipulating Data Part 2

MORGAN KATZ
2 min readJul 23, 2020

Data Type error…

OK this part was slightly more challenging - a data type caused an error. But after scratching my head a while and doing some digging I was miraculously able to change the data types to what I needed! Here’s the error:

After googling for something like “object to int in pandas” I came across the following Stack Overflow page:

I copied the following:

dataframe[‘amount’] = dataframe[‘amount’].astype(int)

And modified it for my scenario:

car_sales[“Price”] = car_sales[“Price”].str.replace(‘[\$\,]|\.\d*’, ‘’).astype(int)

Results shows the Price column is now an int:

I’m glad that’s fixed. Onto Manipulating Data part 3!

--

--

MORGAN KATZ
0 Followers

Business Analyst with an MBA in Business Intelligence. Machine learning student. Exploring data through analysis and solving problems using ML tools.