I’m doing my best to ask my question in a clear manner. This is my first question. Thanks for any replies!
My Code:
autos["price"].str.replace('$','').str.replace(',','').astype(int)
autos["odometer"].str.replace('km','').str.replace(',','').astype(int)
What actually happened, and also what I expected to happen:
0 150000
1 150000
2 70000
3 70000
4 150000
...
49995 100000
49996 150000
49997 5000
49998 40000
49999 150000
Name: odometer, Length: 50000, dtype: int64
This question is in regards to exercise 294, the guided project on eBay cars.
I’m using Jupyter notebook. The output above is what I expected, but here is the problem:
When I examine the dataframe again with autos.head()
, the odometer and price columns are NOT updated. They are still the original strings with dollar signs, commas, and “km.” I thought the code above would replace values in the dataframe, but that doesn’t seem to be happening.
I went back to the last practice exercise but can’t figure out where I went wrong. Am I missing any code like inplace=True
somewhere? Thanks so much for any feedback!
Click here to open the screen in a new tab.