How to get rid of ValueError: could not convert string to float

Can you try the following:

df['income'] = df['income'].str.replace(',', '').astype(float)
df['year'] = df['year'].astype(float)
reg.fit(df[['year']], df.income)

Leave a Comment