diff --git a/section-2-data-science-and-ml-tools/introduction-to-pandas.ipynb b/section-2-data-science-and-ml-tools/introduction-to-pandas.ipynb index b5f48f06f..883cb1c57 100644 --- a/section-2-data-science-and-ml-tools/introduction-to-pandas.ipynb +++ b/section-2-data-science-and-ml-tools/introduction-to-pandas.ipynb @@ -3455,7 +3455,10 @@ ], "source": [ "# Change Price column to integers\n", - "car_sales[\"Price\"] = car_sales[\"Price\"].str.replace('[\\$\\,\\.]', '', regex=True)\n", + "# Step 1: Convert the Price column to string type\n", + "car_sales[\"Price\"] = car_sales[\"Price\"].astype(str)\n", + "# Step 2: Use str.replace() to remove the dollar signs, commas, and periods, and then convert the result to an integer\n", + "car_sales[\"Price\"] = car_sales[\"Price\"].str.replace(r'[\\$\\,\\.]', '', regex=True)\n", "car_sales" ] },