Error string-float

Hi!
I’m trying to use model.fit(data, target) with the csv adult_census, but it always show this message:

ValueError: could not convert string to float: ’ Private’

(and if I remove the feature “occupation” it takes another categorical features…)
Is there a way to fix it?
Thank you for this course and this forum,
Elena

Hello!

Please notice that in this particular notebook we are loading a subset of the csv adult_census called adult-census-numeric.csv.

adult_census = pd.read_csv("../datasets/adult-census-numeric.csv")

The full dataset contains both numerical and categorical values (as will be covered in the following notebooks) and the KNeighborsClassifier() will not know how to deal (compute distances) between raw categorical variables (strings) such as the ones you mention.

Oh now I see, and it totally makes sense.
Thank you very much!
Elena