I've tried so hard to convert the price column to integer. I keep seeing the error message.
Asked
Active
Viewed 70 times
-2

halfer
- 19,824
- 17
- 99
- 186
-
Refrain from showing your dataframe as an image. Your question needs a minimal reproducible example consisting of sample input, expected output, actual output, and only the relevant code necessary to reproduce the problem. See [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) for best practices related to Pandas questions. – itprorh66 Nov 12 '22 at 14:54
-
You're missing the actual traceback; please copy and paste that (starting with `Traceback (most recent call last)`) – TheTechRobo the Nerd Nov 13 '22 at 00:32
1 Answers
0
Please follow the guidelines for posting good examples. However, I suggest using lambda function for this:
car_sales["Price"] = car_sales["Price"].apply(lambda x: int(x.replace('$','').replace(',','')))

Karel Räppo
- 56
- 3