I'm working through the DataQuest Data Analyst path and am on the Laptops dataset. I'm trying to convert a column from string to float (the column contains cpu processor speeds in GHz).
laptops["processor_speed_ghz"] = laptops["cpu"].str.split().str[-1]
laptops["processor_speed_ghz"] = laptops["processor_speed_ghz"].str.replace("GHz", "")
laptops["processor_speed_ghz"] = laptops["processor_speed_ghz"].astype(float)
print(laptops["processor_speed_ghz"].value_counts())
The conversion works perfectly, except that when I inspect the new column, it says the type is int64 instead of float64. Not sure what I'm doing wrong.