dataframe["amount"] = dataframe["amount"].str.replace( [$,.] , ).astype(int)
Make Colour Odometer (KM) Doors Price
0 Toyota White 150043 4 $4,000.00
1 Honda Red 87899 4 $5,000.00
2 Toyota Blue 32549 3 $7,000.00
3 BMW Black 11179 5 $22,000.00
4 Nissan White 213095 4 $3,500.00
5 Toyota Green 99213 4 $4,500.00
6 Honda Blue 45698 4 $7,500.00
7 Honda Blue 54738 4 $7,000.00
8 Toyota White 60000 4 $6,250.00
9 Nissan White 31600 4 $9,700.00
car_sales["Price"].dtype
output-dtype( O )
car_sales["Price"]=car_sales["Price"].str.replace( [$,.] , ).astype(int)
car_sales["Price"]
产出:
0 400000
1 500000
2 700000
3 2200000
4 350000
5 450000
6 750000
7 700000
8 625000
9 970000
Name: Price, dtype: int32