'ValueError: could not convert string to float: 'female' - Insurance Cost Pandas
So, I was about to create a linear regression model to predict insurance cost from this dataset using test set; https://www.kaggle.com/code/annetxu/health-insurance-cost-predicition
Everything seems to be alright from showing the dataset, and split training set and test set, however as soon as I'm trying to using the X_train, it keeps saying, valueerror: could not convert string to float: 'female', I've tried to fix it using methods like, "df['a']=df.a.replace('',np.nan).astype(float)", however it's doesn't make it any different, it's only change the one that could not be converted into female, and when I'm trying another method which is using pdnumeric, it's turned into a different problem, which is "unable to parse female at position 0."
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
